Take the 2-minute tour ×

One of the companies I work with has a web app hosted over a slow DSL line. There is something amiss with the configuration of their server or version of software they are using which means that every page access is triggering a download of a huge collection of JavaScript libraries. According to Firebug the actual contents of each page is delivered relatively quickly so.

Is there a way to force Firefox to consider a particular URL to have a longish expiry period?

Many years ago I used to do this sort of thing on squid proxy installs with custom regex rules to force a minimum cache age for misbehaving sites. What I'm trying to do seems similar but purely client side.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Manipulating a particular cache entry isn't really possible, not even Firefox extensions have that level of access. It is possible to manipulate the headers that the server returns however. Unfortunately, all the existing extensions focus on manipulating the request headers rather than response headers. But an extension for that would be really simple. So maybe you want to try that route before you install Squid again. Here is the code for an extension like that:



  <Description about="urn:mozilla:install-manifest">

    <!-- Firefox -->

    <!-- Front End MetaData -->
    <em:name>Caching header manipulation</em:name>



function install(data, reason) {}
function uninstall(data, reason) {}

function startup(data, reason)
  Services.obs.addObserver(Observer, "http-on-examine-response", true)

function shutdown(data, reason)
  Services.obs.removeObserver(Observer, "http-on-examine-response")

var Observer =
  observe: function(subject, topic, data)
    if (subject instanceof Components.interfaces.nsIHttpChannel &&
        subject.URI.host == "cdn.sstatic.net")
      subject.setResponseHeader("Cache-Control", "max-age=2592000", false);

  QueryInterface: XPCOMUtils.generateQI([

Put these two files into a ZIP archive and rename it into headermanip.xpi - done, you have an extension that will change the caching header for anything coming from cdn.sstatic.net (used on this site) to expire after 30 days rather than the usual 7 days. If you want it to happen on a different host - change the subject.URI check in bootstrap.js. You can also check subject.URI.spec if you want to look at the full URL rather than the host only.

share|improve this answer
add comment

The BetterCache addon looks promising, but its whitelist and blacklist seem to work on MIME types only, not URLs, and according to a review text/javascript should be blacklisted for some captchas to work properly.

I don't think there's a built in way to do this.


And this is where someone proves me wrong.

You could always install squid locally (on the same computer), that's technically client side...

share|improve this answer
add comment

Your Answer


