Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Website CSS & JavaScript slow to update

I've connected to my server via FTP using Visual Studio 2013, and whenever I make changes to my .js or .css files, it takes up to several minutes for my website to update in the browser (same in Chrome, Firefox and IE). Interestingly, my regular HTML code updates instantly.

This is not a cache issue, as I have the "Disable cache (while DevTools is open)" option enabled in Chrome. I have also tried using PHP to add a random timestamp when loading the files, as such:

    <script src="js/site.js?t=<?= time();?>"></script>
    <link rel="stylesheet" type="text/css" href="css/site.css?t=<?= time();?>">

However, simply opening the .js or .css in a new tab reveals that the contents still aren't updated, even though they are in Visual Studio.

Is this a host issue, Visual Studio bug or something with my browsers?

like image 717
david Avatar asked Oct 16 '25 14:10

david


1 Answers

It turned out to be a host feature and I turned it off by entering this at the top of my .htaccess:

Header set Cache-Control "max-age=0, private, no-cache, no-store, must-revalidate"
like image 195
david Avatar answered Oct 18 '25 05:10

david



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!