class StaticAssets::Config

Overview

Configuration for StaticAssets::Handler.

Defaults are tuned for Vite production builds served alongside vite-crystal: /build/assets/* paths are marked immutable with a 1-year max-age, .br and .gz precompressed sidecars are served automatically, and non-immutable files default to public, max-age=0, must-revalidate.

Defined in:

static_assets/config.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(public_dir : String = "public", url_prefix : String = "/", immutable_paths : Array(String) = ["/build/assets/"], immutable_pattern : Regex | Nil = nil, immutable_cache_control : String = "public, max-age=31536000, immutable", default_cache_control : String = "public, max-age=0, must-revalidate", precompressed : Bool = true, etag : Bool = true, last_modified : Bool = true, fallthrough : Bool = true, index_file : String | Nil = nil, headers : Hash(String, String) | Nil = nil) #

[View source]
def self.new(& : self -> ) : self #

[View source]

Instance Method Detail

def default_cache_control : String #

[View source]
def default_cache_control=(default_cache_control : String) #

[View source]
def etag=(etag : Bool) #

[View source]
def etag? : Bool #

[View source]
def fallthrough=(fallthrough : Bool) #

[View source]
def fallthrough? : Bool #

[View source]
def headers : Hash(String, String) | Nil #

[View source]
def headers=(headers : Hash(String, String) | Nil) #

[View source]
def immutable?(request_path : String) : Bool #

Returns true if request_path matches any #immutable_paths prefix or #immutable_pattern.


[View source]
def immutable_cache_control : String #

[View source]
def immutable_cache_control=(immutable_cache_control : String) #

[View source]
def immutable_paths : Array(String) #

[View source]
def immutable_paths=(immutable_paths : Array(String)) #

[View source]
def immutable_pattern : Regex | Nil #

[View source]
def immutable_pattern=(immutable_pattern : Regex | Nil) #

[View source]
def index_file : String | Nil #

[View source]
def index_file=(index_file : String | Nil) #

[View source]
def last_modified=(last_modified : Bool) #

[View source]
def last_modified? : Bool #

[View source]
def normalized_prefix : String #

Returns #url_prefix normalized to a leading / without a trailing / (or "" for root "/").


[View source]
def precompressed=(precompressed : Bool) #

[View source]
def precompressed? : Bool #

[View source]
def public_dir : String #

[View source]
def public_dir=(public_dir : String) #

[View source]
def url_prefix : String #

[View source]
def url_prefix=(url_prefix : String) #

[View source]