views:

157

answers:

1

I'm trying to figure out if redirecting all www.example.com requests to example.com will be beneficial for caching or not, to which end I have 2 questions. SEO is not an issue here.

  1. If the browser requests an image from the www URL (#1) and gets HTTP redirected to the www-less version (#2), will it store the result as cache value for just #2, or #1 as well.

  2. The browser will occasionally ask for a new version of the image (and might get it, or a "Not Modified" response). There will then be an overhead for having to process the redirect every time. Is this overhead larger than the cost of storing two versions of the same image?

A: 
  1. If the browser requests an image from the www URL (#1) and gets HTTP redirected to the www-less version (#2), will it store the result as cache value for just #2, or #1 as well.
    @: See W3C Status Code Definitions for 301. If it's a 301 redirect, it 'should' be cacheable. See How to Redirect a Web Page (301).

  2. The browser will occasionally ask for a new version of the image (and might get it, or a "Not Modified" response). There will then be an overhead for having to process the redirect every time. Is this overhead larger than the cost of storing two versions of the same image?
    @: I'm not exactly sure of this, I suppose if the redirect is handled by the webserver (IIS, apache etc), the overhead should be minimal. Don't quote me though :P

o.k.w
The redirect is done with a RewriteRule, but I'm more concerned about the added round-trip time for the extra request.
Bart van Heukelom
I see, the round-trip time is definitely an overhead. I would like to think it is not going to be significant but I can't quantify it.
o.k.w