CacheBustingConfig class

Cache-busting for asset URLs that embed a content hash.

Typical flow:

Once added to the createStaticHandler, the handler will strip the hash from the last path segment before looking up the file. If no hash is found, the path is used as-is.

"/static/images/logo@abc123.png" → "/static/images/logo.png". "/static/images/logo.png" → "/static/images/logo.png".

Available extensions

Constructors

CacheBustingConfig({required String mountPrefix, required Directory fileSystemRoot, String separator = '@'})

Properties

fileSystemRoot Directory
Filesystem root corresponding to mountPrefix.
final
hashCode int
The hash code for this object.
no setterinherited
mountPrefix String
The URL prefix under which static assets are served (e.g., "/static").
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
separator String
Separator between base filename and hash (e.g., "@").
final

Methods

assetPath(String staticPath) Future<String>
Returns the cache-busted URL for the given staticPath.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
tryAssetPath(String staticPath) Future<String>
Attempts to generate a cache-busted URL. If the file cannot be found or read, returns staticPath unchanged.
tryStripHashFromFilename(String fileName) String

Available on CacheBustingConfig, provided by the CacheBustingFilenameExtension extension

Removes a trailing "<sep>hash" segment from a fileName, preserving any extension. Matches both "name<sep>hash.ext" and "name<sep>hash".

Operators

operator ==(Object other) bool
The equality operator.
inherited