Package com.vaadin.flow.internal
Class StylesheetContentHashUtil
java.lang.Object
com.vaadin.flow.internal.StylesheetContentHashUtil
Computes and caches content-based hashes for stylesheet resources, enabling
cache-busting by appending
?v-c=<hash> to stylesheet URLs. The hash
changes only when file content changes, allowing aggressive browser caching.
For internal use only. May be renamed or removed in a future release.
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendHashToUrl(String url, String hash) Appends a version query parameter to the given URL using the provided hash.static StringgetContentHash(VaadinService service, String resourceUrl) Computes a truncated SHA-256 content hash for the given resource URL.
-
Method Details
-
getContentHash
Computes a truncated SHA-256 content hash for the given resource URL. Returnsnullfor external URLs (http/https), missing resources, or on any I/O error. Results are cached so that each resource is read at most once.- Parameters:
service- the Vaadin service used to load the resourceresourceUrl- the resource path to hash- Returns:
- an 8-character hex hash string, or
nullif the hash cannot be computed
-
appendHashToUrl
Appends a version query parameter to the given URL using the provided hash. Returns the original URL unchanged if the hash isnull.- Parameters:
url- the original URLhash- the content hash, ornull- Returns:
- the URL with
?v-c=<hash>or&v-c=<hash>appended, or the original URL if hash isnull
-