Jump to content

Forcing browser to reload CSS stylesheets - is this code the best way?


Zola

Recommended Posts

Hi all

 

I have a big global stylesheet for a website that I update quite regularly. One thing that bugs me is that once I update the CSS file and overwrite it, the site usually needs refreshed in the browser to see changes, or else things could appear out of sync.

 

I did a little research on my problem and found these bits of code. From my understanding this code (placed at the very top of the document before the site loads), will tell the browser to ditch the memorised stylesheet and load it fresh.  

Is this correct?  If so should I only have it in use on the index page now and again after a few big updates?

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.