Preventing CSS Files From Getting Cached
#1
Ok this is one thing that has REALLY annoyed me. I am using nginx and its not even using caching yet if I clear my cache it does not update.

So what I have done that you can do as well is use the query string trick to force an update. We are going to append a timestamp to the file as dateline=timestamp.

Open up global.php. Find:

$stylesheets .= "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$mybb->settings['bburl']}/{$page_stylesheet}\" />\n"; 
on around line 236.

replace it with:

$stylesheets .= "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$mybb->settings['bburl']}/{$page_stylesheet}?dateline=".time()."\" />\n";

Save it and now when ever you change a css file it will always been showing without clearing your cache as the browser sees it as a new file.

You could also do something like x=randomint&y=randomint but i think this way is simpler and guaranteed that you will nefer get 2 of the same numbers twice Smile.

Also I would like to see this in the offical MyBB builds as it is useful, so think about it devs Smile.

Peace..
Reply


Messages In This Thread
Preventing CSS Files From Getting Cached - by pcfreak30 - 2012-06-10, 03:27 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)