5
votes

Is it possible for a client to override and/or ignore HTTP Cache-Control headers of dynamically-loaded content (e.g. images loaded asynchronously) using JavaScript?

My JavaScript-based GIS application requests images dynamically from an outside server who sends the following header with its response:

Cache-Control:max-age=0,must-revalidate

This results in the browser sending duplicate requests for the same images (along with If-None-Match request header) which always results in an HTTP 304 Not Modified response, so the cache is used anyway but only after a delay.

I already know the images have not changed, but I don't have any control over the cache-control header sent by the server, so I would like to force use of the local browser cache when displaying the image without having to first revalidate with the server.

Is it possible to change this on the client side?

1

1 Answers

-2
votes

You should be able to override the local cache from javascript by doing a location.reload(true) but not all browsers behave properly - use a frame to repopulate non html content