Forum Moderators: phranque
I have a folder for site images on my site. Using ySlow, I am getting an F for a cookie-free domain.
Lots of my images have cookies attached to them I would guess.
Is there a way in the apache configuration to exclude cookies from being used in a specific web folder?
Thanks in advance! If you have any questions, please feel free to ask.
Tom
It does not make sense for ySlow to 'blame' you because the client sends the cookie to your domain with every HTTP request. However if your server is trying to set a cookie in response to every HTTP request, then that might deserve an "F" grade.
Let's be clear on what a cookie is: The server sends a Set-Cookie HTTP response header to the client that says, "Whenever you send me an HTTP request, send this data back to me with an HTTP "Cookie" header."
Usually a cookie is set once, or set when the user changes his preferences, or set when the user changes pages (tracking cookie). Cookies also have "realms" which are essentially "subdirectory branches." The problem is that you can easily set what realm (subdirectory-path) the cookie *does* apply to, but it's not possible to specify what realm it *does not* apply to.
Have you tried looking at the client/server cookie interaction using the Live HTTP Headers add-on for Firefox/Mozilla? -- That might clarify the situation a bit.
Jim
At this moment, I'm trying to figure out if there is a way to do mod_rewrite on on images links within pages.
For example
I have a webpage at http://www.example.com/sub-dir/index.php
This page contains images at http://www.example.com/_images/
Ie. http://www.example.com/_images/my-image.jpg
I created a whole new virtual server at /var/www/images/ and a soft link
ln -s /var/www/images /var/www/html/_images
(Any images referenced from /var/www/html/_images will hopefully point to [images.example.com...]
ie. http://www.example.com/_images/my-image.jpg to [images.example.com...]
In my htaccess file I have so far
RewriteEngine on
#RewriteLog /var/log/httpd/mod_rewrite.log
#RewriteLogLevel 3
RewriteBase "/_images"
#RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^_images/$1 [images.example.com...] [R]
Don't quite have it yet.
Is what I'm trying to do even possible? Am I using the right approach? Or is there a better approach?
Please feel free to let me know. Thanks!
[edited by: jdMorgan at 4:15 pm (utc) on July 7, 2009]
[edit reason] example.com [/edit]
It is very helpful to solving these problems to remember that URLs are used on the Web, and filepaths are used inside the server, and that the two are not "equivalent" or "similar" in any way, but only "associated" by the action of the server itself. So don't confuse these two "object location domains," and keep in mind that all you need to do is to make shared image *files* appear to be duplicated in the filespace used by "www.example.com".
If however, you want the images fetched using a different domain (e.g. to speed the site up a little), then the answer is simple (if not what you want to hear): change the links on your pages to point to the proper new image URLs. mod_rewrite cannot be used to 'fix' URLs, it can only be used to change the requested-URL-to-filepath mapping. Trying to use it to 'change URLs' will result in doubling the number of requests to your server, slowing down your site, and polluting your log files and stats, because every image request will be redirected and result in a second HTTP request -- quite the opposite result from that usually desired...
Jim