JParriki Posted November 25, 2016 Share Posted November 25, 2016 Hello community, I would like to know if it is possible to clear only the css cache from a module. I have a module with styles and javascript but without views (I only use the hookDisplayHeader on the module). I only use it to make my own styles and javascript without have to touch any other css files. The problem is that when I make a change, some users don´t see the change because they have the file on cache. I tried to use the Cache class from prestahop but it doesn´t work, I think I don´t use the class on right way. Other thing that I tried, was to put on the htacces the following code, but it didn´t work. <filesMatch "\.(html|htm|js|css|php)$">FileETag NoneHeader unset ETagHeader set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"Header set Pragma "no-cache"Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"</filesMatch> I also wrote on the main "index.php", that is on the root folder, this code: header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1header("Expires: Sat, 1 Jul 2000 05:00:00 GMT"); // Fecha en el pasado Anyone can help me? PD: Sorry for my English Link to comment Share on other sites More sharing options...
bellini13 Posted November 25, 2016 Share Posted November 25, 2016 If the styles are already cached in the visitors browser, then you must wait for those to expire or physically clear that browser cache. The alternative is to rename the modules css files which would force the visitor to download it 2 Link to comment Share on other sites More sharing options...
JParriki Posted November 25, 2016 Author Share Posted November 25, 2016 Hello ballini13, Thanks for you reply. I change the files that I need and this works for me. Thanks!!! Goodbye Link to comment Share on other sites More sharing options...
Krystian Podemski Posted November 25, 2016 Share Posted November 25, 2016 You can also switch between CCC enabled and disabled to regenerate cached files. Link to comment Share on other sites More sharing options...
bellini13 Posted November 26, 2016 Share Posted November 26, 2016 You can also switch between CCC enabled and disabled to regenerate cached files. This would be true if he was referring to the server side cached files. However he is referring to the client side cached style sheets Link to comment Share on other sites More sharing options...
chulucanas Posted July 16, 2019 Share Posted July 16, 2019 On 11/25/2016 at 1:15 PM, bellini13 said: ... The alternative is to rename the modules css files which would force the visitor to download it Best answer I found on the internet so far. Thank you Link to comment Share on other sites More sharing options...
Costantini Posted May 17, 2020 Share Posted May 17, 2020 On 7/16/2019 at 12:22 PM, chulucanas said: Best answer I found on the internet so far. Thank you how did you solve it? we have the same problem. Link to comment Share on other sites More sharing options...
Edvinas Posted April 21, 2022 Share Posted April 21, 2022 /** * Clear theme cache. */ public static function clearCache() { $files = array_merge( glob(_PS_THEME_DIR_ . 'assets/cache/*', GLOB_NOSORT), glob(_PS_THEME_DIR_ . 'cache/*', GLOB_NOSORT) ); foreach ($files as $file) { if ('index.php' !== basename($file)) { Tools::deleteFile($file); } } $version = (int) Configuration::get('PS_CCCJS_VERSION'); Configuration::updateValue('PS_CCCJS_VERSION', ++$version); $version = (int) Configuration::get('PS_CCCCSS_VERSION'); Configuration::updateValue('PS_CCCCSS_VERSION', ++$version); } This with some adjustments should fit anyones needs 😁 File: classes/Media::clearCache() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now