Search code examples
jqueryhttphttp-headersbrowser-cachehttp-caching

Is jQuery cache disabling trick needed if a server returns cache prevention headers?


I need to fully prevent caching of Ajax calls results. Jquery ajax() function has acache: false option for this. The option appends timestamp to each requested resource (?_=1353592676117). This should do the job, but is not very elegant. It pollutes logs and can be puzzling for someone not familiar with the trick.

Is enabling this option ever needed if the server returns a correct set of cache prevention headers (no-cache, no-store, must-revalidate, optionally also max-age=0)? If so, in which cases headers are not enough?


Solution

  • You don't need to set cache: false flag if you are setting correct cache prevention response headers at your server.