How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
I use a custom less file. As many others I add new less code in the file every now and than. CSS files are often cached and only downloaded if there is a new version of the file. Many companies use variables behind the css extention to show the version let's say master-7e672b025b8357c06dd23d8133e9e743.css?v=20160721 (date of today or something like that).
I managed to add ?v=20160721 in the [root]/libraries/gantry/core/gantry.class.php file and after compiling I actually see in the css-compiled directory exactly what I want.
However, the file master-7e672b025b8357c06dd23d8133e9e743.css?v=20160721 is not part of the source code of the webpages. So I miss CSS while visiting webpages. Any suggestion how to make this work?
Last Edit: 8 years 9 months ago by Louis. Reason: No replies yet
First things first but not necessarily in that order
Re: How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
Yes you need to make a custom css file in Gantry 4 you do it like this...
To create a custom CSS file, you just have to create a new css file at /templates/[TEMPLATE]/css/ and name it [TEMPLATE]-custom.css. The new custom CSS file will automatically get loaded by the Gantry 4 Framework.
NOTE: The use of [TEMPLATE] in this guide is intended as a placeholder for the name of the template's primary directory. Replace [TEMPLATE] with the template directory name in order for these instructions to work with your site.
docs.gantry.org/gantry4/tutorials/adding-a-custom-stylesheet
Re: How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
Tnx Damir but that is an anwer to a different question. As I mentioned I already have a customer css and less files which works like you explain. I want to prevent caching these files (for less the compiled-css file) in order to serve returning visitors the update css file which currently has the same name. Any suggestions how to solve the original topic question?
Kind regards,
Louis
First things first but not necessarily in that order
Re: How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
The files will never have the same name and every-time you save Gantry settings you can clear the cache in Gantry and all files are deleted but there is no point in doing that because the chances for the same name are zero to none 7e672b025b8357c06dd23d8133e9e743 this number is getting generated and its always different ... and returning visitors will never see the old css file if new one is present from Gantry ...
Re: How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
That still does not answer the question. I am not changing anything in the Gantry settings. I want to add less code to my customer less file. That file will be part of a compiled-css file. And the name of that last file will NOT change if I add stuf in my custom-css file.
However, your answer sounds like a work-around. Simply change 1 setting in gantry template settings and the file name will change.
But how would this work for the custom css file that is not part of a compiled css file?
First things first but not necessarily in that order
Re: How to prevent caching of edited compiled-css files?
Posted 8 years 9 months ago
That file [TEMPLATE]-custom.css. does not get cached its always reloaded when user visits a page ... the thing you are trying to do is rather complicated this would require to rewrite some stuff in gantry to add date next to the file name and to load that in the code when new stuff is added ... but what if you will use RokBooster or similar stuff for caching and optimization then this doesn't make sense ....