Your editing seems to be having no effect - browser cache problems

Last modified: December 8, 2008 - 06:26

These two Firefox extensions are useful for clearing up site development problems caused by server files being cached by the browser.

These are great for those frustrating situations where you repeatedly edit a file on the server, but it appears to have no effect, because (you eventually realize) your browser is still using the old cached version that it fetched 20 minutes ago.... in my experience this seems to happen quite often with css, js and xml files

CacheViewer (view and delete individual browser cache files)
https://addons.mozilla.org/en-US/firefox/addon/2489

Johnnycache (stop the browser from fetching certain files from the cache)
https://addons.mozilla.org/en-US/firefox/addon/3817

Use Cacheviewer to delete individual files from the browser cache (delete them one at a time because the multiple select and delete doesn't work). This is foolproof, because if the file isn't in the cache any more, you can be certain the browser will be forced to get the new version from the server.

Cacheviewer is also useful for a general understanding of WTF is going on, such as finding out which files the client is downloading, when they were last grabbed and precisely which path they're coming from. (although other Firefox addons, like FireBug, can help here as well).

In theory, Johnnycache can prevent cache access for individual files or paths - which would be perfection. In practice, this doesn't work in some cases (maybe I'm giving it the wrong path somehow).

You can use Johnnycache to block caching for the entire site under development (just use yoursitename.com). This always works, but it can slow down loading of complex pages. But I'd suggest doing this when you first install Johnnycache, to get an idea how it works.

Note that Drupal also has its own internal caching system which might cause issues similar to those described on this page - for anonymous users only. It can be turned off while you're developing your site (not recommended when site is accessible to the public). Go to Administer › Site configuration › Performance to turn it off. In Drupal 6+, if you need to keep caching on, there's a button to clear the cache.

The only other caching problem these addons can't protect you from is your ISP's badly-configured proxy invisibly caching the files. One way to detect this situation is to rename the file on the server - thereby bypassing the proxy the next time the file is fetched.

Related Issue - take care with old files and folders

There's another quite different issue that might have the same effect of making edits seem useless.

To take one example: You copy a theme directory, e.g. to make a quick backup. You give the copy a different name, of course. You leave that copy in the same place (inside the same directory) as the original. You assume that Drupal will continue to use the theme files in the original folder (well, why not? it hasn't moved and the name is still the same). But in fact Drupal may start using the theme files from the wrong folder, even though you have changed its folder name.

In some situations, Drupal can search parts of the file system for files it needs. This is a useful feature, but it means that it is a bad idea to leave old copies of files and folders lying around inside your Drupal directory and its sub-directories. This guideline definitely applies to theme folders, module folders and template (tpl.php) files, maybe to others as well.

 
 

Drupal is a registered trademark of Dries Buytaert.