class
StaticAssets::Config
- StaticAssets::Config
- Reference
- Object
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.crConstructors
- .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)
- .new(& : self -> ) : self
Instance Method Summary
- #default_cache_control : String
- #default_cache_control=(default_cache_control : String)
- #etag=(etag : Bool)
- #etag? : Bool
- #fallthrough=(fallthrough : Bool)
- #fallthrough? : Bool
- #headers : Hash(String, String) | Nil
- #headers=(headers : Hash(String, String) | Nil)
-
#immutable?(request_path : String) : Bool
Returns
trueifrequest_pathmatches any#immutable_pathsprefix or#immutable_pattern. - #immutable_cache_control : String
- #immutable_cache_control=(immutable_cache_control : String)
- #immutable_paths : Array(String)
- #immutable_paths=(immutable_paths : Array(String))
- #immutable_pattern : Regex | Nil
- #immutable_pattern=(immutable_pattern : Regex | Nil)
- #index_file : String | Nil
- #index_file=(index_file : String | Nil)
- #last_modified=(last_modified : Bool)
- #last_modified? : Bool
-
#normalized_prefix : String
Returns
#url_prefixnormalized to a leading/without a trailing/(or""for root"/"). - #precompressed=(precompressed : Bool)
- #precompressed? : Bool
- #public_dir : String
- #public_dir=(public_dir : String)
- #url_prefix : String
- #url_prefix=(url_prefix : String)
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)
#
Instance Method Detail
def immutable?(request_path : String) : Bool
#
Returns true if request_path matches any #immutable_paths prefix or #immutable_pattern.
def normalized_prefix : String
#
Returns #url_prefix normalized to a leading / without a trailing / (or "" for root "/").