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");
Edited by Zola
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.