Klynton
Klynton

Reputation: 171

GWT Internet Explorer Caching AJAX Responses

I have some client-server interaction and GWT is updating the webpage and making it look dynamic. This is working on Chrome and Firefox, however, IE (8,9,10) is caching the Responses. I am able to tell that its caching because I used httpwatch to view the exchange.

https://i.sstatic.net/USouG.png

As you can see these Responses are being cached, how can stop IE from aggressively caching like Chrome and Firefox?

Upvotes: 1

Views: 775

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

The browser is allowed to cache a) any GET request with b) the same url unless c) the server specifies otherwise. With those three criteria, you have three options:

  • Stop using GET, and use a POST instead. This may not make sense for your use case or your server, but without any further context in your question, it is hard to be more specific
  • Change the url each time the resource is requested. This 'cache-busting' strategy is often used to let the same file be loaded and not need to worry if it changed on the server or not, but to always get a fresh copy
  • Specify headers from the server whether or not the file should be cached, and if so, for how long.

If you are dealing with the <module>.nocache.js and <hash>.cache.html files, these typically should get a header set on them, usually via a filter (as is mentioned in the how to clear cache in gwt? link in the comments). The *.cache.* files should be kept around, because their name will change automatically (see bullet #2 above), while the *.nocache.* should be reloaded every time, since their contents might have changed.

Upvotes: 2

Related Questions