views:

115

answers:

3

I want to use the same image more than once and I would like the web browser to download this image only once, how to do it?

+8  A: 

The browser will cache the image for you - no worries.

mmsmatt
+2  A: 

HTTP 1.1 introduced a new class of headers, Cache-Control response headers, to give Web publishers more control over their content, and to address the limitations of Expires.

  • Make caches store images and pages that don’t change often by using a Cache-Control: max-age header with a large value.
davidrobles
As a developer, what can I do?
Steven
@Steven - The web browser will send GET /image to the webserver, along with the "IF-MODIFIED-SINCE: (date the web browser last downloaded it)" header. If the server sees that the web browser's image is current, it won't get downloaded. (see section 14.25: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)As a developer, just make sure your webserver speaks fluent HTTP 1.1. (You can also tweak the headers to change behavior if you need to).
Seth
A: 

Once the image is cached by the browser you can show that same image millions of times without having to reload it again. There's no reason to worry about this being an issue.

Michael Mad