Understanding Image Caching in Web Browsers

What is the complete set of factors affecting image caching in web browsers? How much control does this web developer control and how many browser settings? Are there different considerations for other types of assets (e.g. scripts, audio)?

thanks

+4
source share
2 answers

A complete set of factors:

  • HTTP headers that affect caching
  • user agent (browser) built-in caching behavior
    • can be changed using user settings, depending on UA
    • including private view modes that they can use and then clear a separate cache per session.
  • user actions, such as manually clearing the cache

Web developers have very little control, but that's fine. Remember that caching is performed in the interests of the end user, as a rule, to reduce the page load time, and it is generally inappropriate for you to know all considerations specific to each user.

The bit you can control is expiration time and behavior without a cache. They respectively indicate that the user wants to restore the resource because it is expected that it will change or not be cached for other reasons.

Browsers may process images differently than other resources (mostly different after default expiration when not specified), but you can send HTTP headers for any resource.

+1
source

On the client side, check if the client browser sends the If-Modified-Since header to the server. If the client sends the header, IIS will respond with 304 Not Modified and therefore the client will use its local cache to display / use the file.

The client settings are responsible for this. IE → Tools → Internet Options → Browsing History → Settings → Automatically ensures that this happens. For this setting, different browsers will have different areas.

For scripts / audio, you can put them in a special folder for the content and simply set the expiration of the content from your server so that the server sends the appropriate information to the client to cache the file upon request. However, this will not be the installation of the developer.

Developer setup is usually for dynamic files. Based on the language [in ASP.NET, the OutputCache directive creates different cache headers], this will change.

0
source

All Articles