I have a webpage that returns the following title when accessing the material:
HTTP/1.1 200 OK Date: Sat, 29 Jun 2013 15:57:25 GMT Server: Apache Content-Length: 2247515 Cache-Control: no-cache, no-store, must-revalidate, max-age=-1 Pragma: no-cache, no-store Expires: -1 Connection: close
Using the chrome extension, I want to modify this response header so that the material is actually cached rather than wasting bandwidth.
I have the following code example:
chrome.webRequest.onHeadersReceived.addListener(function(details) { // Delete the required elements removeHeader(details.responseHeaders, 'pragma'); removeHeader(details.responseHeaders, 'expires'); // Modify cache-control updateHeader(details.responseHeaders, 'cache-control', 'max-age=3600;') console.log(details.url); console.log(details.responseHeaders); return{responseHeaders: details.responseHeaders}; }, {urls: ["<all_urls>"]}, ['blocking', 'responseHeaders'] );
Which correctly changes the header to something like this (based on the output of console.log ()):
HTTP/1.1 200 OK Date: Sat, 29 Jun 2013 15:57:25 GMT Server: Apache Content-Length: 2247515 Cache-Control: max-age=3600 Connection: close
But on the basis of everything that I tried to check, I do not see any evidence that this actually happened:
cache does not contain an entry for this file- The
Network tab in the Developer Console does not show any changes for the HTTP response (I tried changing it to trivial modifications just to make sure that this is not an error, but still no changes).
The only real clues I can find is this question , which says that my approach is still working, and this paragraph on the webRequest API documentation , which suggests that this will not work (but does not explain why I cannot get any changes):
Note that the web request API is an abstraction of the stack network to the extension. Inside, one URL request can be divided into several HTTP requests (for example, to select individual byte ranges from a large file) or it can be processed by the network stack without communication with the network. For this reason, the API does not provide the final HTTP headers that are sent to the network. For example, all headers related to caching are invisible to the extension.
Nothing works (I canβt change the HTTP response header ), so I think that is my first problem.
Any suggestions on where I might be wrong, or how to find what is going wrong here?
If this is not possible, are there other ways to achieve what I am trying to achieve?