New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.x - Cache busting #149
Comments
What would be used as version number ? The file timestamp ? |
Yes, my personal solution uses the But of course this could be optionally set to any number. What do you suggest to use? Should there be a build-process that can be triggered manually by the developer and that generates either a big lookup table or that modifies the twig templates directly? |
I usually use gulp or webpack to compile the assets and generate a json file containing all the hashes. |
So you suggest to use a big lookup table, which means a json file containing a map of file paths to file hashes? If you have thousands of asset files, but every page uses 15-20 assets only, is this really better than the Both methods have their pros and cons. How about writing a twig lexer/parser/compiler that transforms file paths to hashed paths upon template compilation? |
You're right. But i think is better a single json than multiple filesystem interactions. |
Why not cache bust via query string instead?
|
@l0gicgate Because some browsers didn't see a different query string as a different file and there are cache proxies that do not cache files with query strings at all. I think that the whole cache busting thing should be implemented in another repository (as extension to this one). This wouldn't be base functionality anymore. What do you think? |
Actually, this is not even Slim specific. It is Twig specific. |
For cache busting see https://css-tricks.com/strategies-for-cache-busting-css/
Personally I made a cache busting twig function that transforms the given path automatically. So if there is a file
/public/image.jpg
and in the template I writethen that would be transformed into
in case the base path is
base-path
.Of course the web server needs to be configured such that it redirects those cache busting urls.
What do you think, should we implement that twig function or is this already beyond the slim philosophy?
The text was updated successfully, but these errors were encountered: