Search code examples
javascripthttpiisinternet-explorer-11browser-cache

Browser Caching - Why do I see repetitive http requests for javascript files if they are cached?


I am trying to improve performance of few web pages and wanted to understand if the javascript files are cached by I.E or not for my internal application. So, I had fiddler to watch the requests going to server.

I can see, every single time a create customer page is loaded, the same number of requests in the fiddler, for the same files with Result '200' (and not 304 - not modified ) to fetch javascript files. These include jquery, knockout and a few custom ones.

I studied the request and response header (below) but I see cache-control to be ok and nothing that conveys it is not cached. But don't understand why these same http requests show up in fiddler (which conveys a request is actually made to server) if it is cached.

I can see the same requests every time going to server, which makes me wonder :

  1. Is the browser caching these or not ?
  2. If not, are these atleast cached in IIS ?
  3. How can I avoid these unnecessary http requests, since these javascript files dont change at all ?

enter image description here

Many Thanks.


Solution

  • Your request for the file has a Pragma: no-cache header (up at the top of your image, two lines under "Request Headers"), which tells the browser and the server that you don't want to use the cached copy.

    You'll want to look at how you're making that request to find out why that header is there, and get rid of it.

    Possibilities:

    • You're loading it via some kind of AMD or other dynamic loading mechanism that is configured to not use cache

    • You're running with development tools with the "disable cache" option most of them have turned on