Cache busting with php time11/19/2023 A Very Brief History of Cache BustingĪs a result, based on the default behavior of a cephalopodically-named piece of proxy software, developers have for years forced browsers to update resources using “revved” (or revisioned) file names instead of query strings (who knew squids could be so persuasive?): It would have been nice if others had been discussed, but I suppose if one major proxy has this problem, then that would be enough to warrant changing from query string revving to some other method. It’s notable that the only proxy that Souders mentions is Squid. This means that if users are viewing your content through such a proxy, you’ll get the benefit of immediately-updated resources but you won’t get the benefit of caching. The gist of the Souders piece is that certain web proxies will not cache resources that use a query string in the URL. The user pointed to a Steve Souders article from 2008 that discusses why it’s best to change the file name itself rather than append a query string. One of the comments in that quick tip of mine mentioned that it’s not recommended to use a query string value to update a resource. So instead of showing the user the cached version, it makes a new request to download the content again, thus retrieving a freshly updated resource. It basically tricks the browser into thinking that the resource being requested is different, even though it has the same file name. To this day, I still get decent search traffic on that page from people looking for ways to do this. In fact, shortly after seeing this in H5BP, I wrote a quick tip describing how to use this technique to force a browser to update your stylesheet. You can see this implemented in a really early version of HTML5 Boilerplate. To solve the second problem, the first thing I can remember developers trying was adding a query string value to a resource’s URL. htaccess file to do this, as found in HTML5 Boilerplate: ĮxpiresByType text/css "access plus 1 year" Here’s part of what you might include in your. And this will remain so as long as the user doesn’t erase their browser cache. This ensures the resources are cached for a specified time period (usually a year or more). To help solve the first problem, most developers use far-future expires headers in their. make a few changes to a stylesheet), you don’t want the user to get the old cached version you want the updated version to take effect on the first visit. You want resources to be cached more or less indefinitely. The problem is that those two things are in opposition to each other. “cache bust”) as soon as they’ve been updated, so users aren’t fed out-of-date files
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |