Replies: 1 comment
|
Thank you for your proposal and pull request (#418). I merged the pull request with some minor changes. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The
timestamp_publicplugin generates cache-busting paths usingFile.mtime(). This works well in traditional deployment environments, but does not work correctly in all containerized environments.When building a Docker image, the mtime of files inside the image reflects the mtime on the build host. For example, in a typical CI/CD pipeline using GitHub Actions,
git checkoutsets the mtime of every file to the checkout time, so each deployment produces a fresh set of mtime values even when file content has not changed. Whether cache-busting works correctly therefore depends on how and wheredocker buildis executed — a dependency that is better avoided.A content hash is deterministic regardless of the build environment: as long as the file content is the same, the cache-busting path stays the same.
Roda's
assetsplugin does support content-based hashing for compiled assets, but it only handles CSS and JavaScript files. For other static files such as images, fonts, and downloadable documents,timestamp_publicis currently the only cache-busting option available. This gap makes a content-hash-based alternative particularly valuable.Proposal
Add a new
hash_publicplugin that uses a digest of the file content (e.g. SHA256) instead of mtime to generate the cache-busting path segment.Example usage:
Design notes
timestamp_public(ahash_pathhelper and anr.hash_publicrouting method), keeping it familiar to existing users.:lengthoption to truncate the hash (e.g. 16 characters). Even a truncated hash provides far more uniqueness than is needed for cache busting.Stringmatcher (hex pattern) instead of theIntegermatcher thattimestamp_publicuses, which is one reason a separate plugin makes more sense than adding an option totimestamp_public.assetsplugin already usesSHA256for compiled asset filenames (asset_digest), so there is precedent for content-based hashing in Roda.All reactions