0

We are facing some major problems with the browser cache. After we have done the development on our website, the changes are not reflecting to the end user and they need to clear the browser cache at each and every time when the new changes occurs. Its really annoying and affects our business.

How can we stop this issue?

2 Answers 2

1

You can set disable browser cache in .htaccess file. See below code. After 1 or 2 days you can remove code so cache page again.

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>
2
  • But, It will not help to end users, right?
    – Tim
    Aug 17, 2020 at 12:51
  • it will help like we had one css dynamically generated which should be update without clear cache on end user's system. so we had set expire header in htaccess Aug 17, 2020 at 13:24
1

To overcome these issues Magento features Static Content Signing which allows you to invalidate the browser cache. Flush JavaScript/CSS Cache after deployment if the changes are not reflecting.

Static content signing:

Magento feature that allows you to invalidate the browser cache for static resources. Magento accomplishes this by adding a deployment version to the URL of static files.

php bin/magento config:set dev/static/sign 1

For more detail, please refer to this link Static content signing

Flush JavaScript/CSS Cache:

Removes the merged copy of JavaScript and CSS files from the cache. If recent changes to the style sheet or JavaScript aren’t reflected in the store, try flushing the JavaScript/CSS cache and refreshing your browser.

  • Path: Admin sidebar > System > Cache Management > Additional Cache Management > Flush JavaScript/CSS Cache
1
  • Already the option is enabled but still the browser cache issue is there. Please advice what else to check
    – Tim
    Aug 17, 2020 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.