Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asking browsers to cache as aggressively as possible

This is about a web app that serves images. Since the same request will always return the same image, I want the accessing browsers to cache the images as aggressively as possible. I pretty much want to tell the browser

Here's your image. Go ahead and keep it; it's really not going to change for the next couple of days. No need to come back. Really. I promise.

I do, so far, set

Cache-Control: public, max-age=86400 Last-Modified: (some time ago) Expires: (two days from now)

and of course return a 304 not modified if the request has the appropriate If-Modified-Since header.

Is there anything else I can do (or anything I should do differently) to get my message across to the browsers?

The app is hosted on the Google App Engine, in case that matters.

like image 229
balpha Avatar asked Mar 11 '10 15:03

balpha


People also ask

How do I leverage my browser cache?

To leverage your browser's caching generally means that you can specify how long web browsers should keep images, CSS and JS stored locally. That way the user's browser will download less data while navigating through your pages, which will improve the loading speed of your website.


1 Answers

You may be interested in checking out the following Google Code article:

  • Optimize caching: Leverage browser caching

In a nutshell, all modern browsers should be able to cache your images appropriately as instructed, with those HTTP headers.

like image 173
Daniel Vassallo Avatar answered Oct 17 '22 06:10

Daniel Vassallo