views:

61

answers:

2

So I'm wondering how browsers treat requests for images. I'm hoping to use a cdn for serving product images on my website. I'd also like to use the cdn for serving button images and images used in my css.

The problem with this is that I don't have control over the expires headers (Rackspace files is what I'm looking into).

See, say I have a large image file as a background on my home page. So the page is accessed often, but the image stays the same. Is the browser going to request this image every time?

Or should I just use a cdn for my product images?

A: 

No, AFAIK you need necessarily to add the 'cache' header to your images to enable browser caching. This is a great tutorial about it.

Additionally you can read this article from Yahoo to get a very brief view of the topics.

Review specially these topics of the article:

  • Minimize HTTP Requests
  • Add an Expires or a Cache-Control Header
  • Use a Content Delivery Network

Hope it helps you

SDReyes
Just out of curiosity how exactly do you "add the cache header" to an image? You are not referring to request headers, are you?
JoseMarmolejos
Nope, in fact it is a reponse header. I would like to see how can you do it with a request header....
SDReyes
Oh, the cache-control. of course thx : )
SDReyes
No, the cache-control is a response header ... before participating in discussions like this one I suggest you take a look at an every day GET request using fiddler or firebug, you'll be amazed at the things you'll learn. And btw, I'm still curious about how would you "add the cache header to an image" ...
JoseMarmolejos
Of course, for example with IIS you can use HTTP caching manually with individual images -but I don't think you really want to do so :P-, also you can apply it to entire mime types. Karin Huber published an interesting article about how to do so in IIS a while ago http://bit.ly/9Cssr9.
SDReyes
A while ago? That article is two years old ... and btw, you should read it and contrast it with what you suggested in the first place. Apples and oranges.
JoseMarmolejos
I'm citing it just to give you an explanation you're asking for, not as fundament of this answer, Jose.
SDReyes
I understand your point, Probably my answer was not clear enough. but at the end we cited the same source. I was not trying to say: "Hey cache manually all those images", I was talking about find a way to add the adequate http headers to those resources. :P my redaction errors, sorry hehehhe
SDReyes
+1  A: 

Hi Matthew, caching is quite a broad subject. I suggest you start by reading about the different kinds of caching here http://www.mnot.net/cache_docs/#BROWSER and how caching works here http://www.web-caching.com/mnot_tutorial/how.html

Now, to answer your question: assuming the user has caching enabled and the cdn response headers are properly configured a user visiting your page multiple times will only request that background image once until the cache expires or those files are cleaned.

JoseMarmolejos
Fine, we finished citing the same document :P
SDReyes
the Cache-Control solution is new for me. I though it was always done server side. thanks Jose +1
SDReyes