

Some mobile providers will compress or alter content, in particular images, to save bandwidth when re-transmitting content over cellular networks. The "no-transform" option may be important for mobile users.

A better option to add is "no-store" which will prevent request and response from being stored by the cache. For example the "no-cache" option just implies that the proxy should verify each time the page is requested if the page is still valid, but it may still store the page. Other options are sometimes used inappropriately. A proxy will not cache a page if it is marked as "private". Most importantly, the page can be marked as "private" or "public". There are a number of options associated with this header. This is probably the most important header when it comes to security. The server needs to include appropriate headers to indicate if the response may be cached. It is the goal of properly configured caching headers to avoid having personalized information stored in proxies. However, HTTPS inspecting proxies are available and common in some corporate environment so this *may* apply to them, even though I hope they do not cache HTTPS content. The browser does not typically cache HTTPS content, and proxies will not inspect it. I think this is a good reason to talk a bit about caching in web applications and why it is important for security.įirst off all: If your application is https only, this may not apply to you. The headers allowed authenticated content to be cached, which may lead to sessions being shared between users using the same proxy server.
#PROBLEM WITH PRIVATE CACHE CONTROL UPDATE#
This can apply to all of our css, js, and images files (max-age=31536000) after we change something, the browser will just request a new file with a new hash sum, which it will then cache.Earlier this week, an update for Media-Wiki fixed a bug in how it used caching headers. So, after next the deployment, you will get a new version of the file. Even small changes to the the file are reflected in the hash sum, which guarantees that it will be recognized as different. Each file will be precompiled on the server and hash sums are added to the file names, such as “app-72420c47cc.css”.
#PROBLEM WITH PRIVATE CACHE CONTROL DOWNLOAD#
So, to force the browser to download a new version of the needed file, we use a technique implemented by many assets builders tools, like Webpack or Gulp. But how can we be sure that file won’t change for so long? We don’t. With this policy, the browser completely skips the process of making requests to your server and opens files very fast. The time that the browser should keep the file in cache should be defined in seconds, typically presented like this Cache-Control: max-age=31536000. This directive allows us to tell the browser how long it should keep file in the cache since the first load. This increases load times of the affected site, adds extra load to your web server when transferring information, and increase the number of calls to your backend.

Without cache control settings, the browser goes to the web server for every request for resources and reads information from it. The most common directives involved in the cache process are “Cache-Control”, “Expires”, “Etag” and “Last-Modified”.Īlmost every web server has some cache settings in header responses by default, but it isn’t clear what we get if there are no cache policies. These instructions function as directives to tell your browser about them, you must add them to response HTTP header information. This is only possible we provide enough instructions for the browser, to explain what resources it needs to keep and for how long. Your browser, on each request to the website/resource, tries to load as little data as possible by reading cached information from local memory. How does the cache work behind the scenes?
