.htaccess, YSlow, and "Use cookie-free domains"
Asked 07 September, 2021
Viewed 1.4K times
  • 51
Votes

One of YSlow's measurables is to use cookie-free domains to serve static files.


  

"When the browser requests a static image and sends cookies with the request, the server ignores the cookies. These cookies are unnecessary network traffic. To workaround this problem, make sure that static components are requested with cookie-free requests by creating a subdomain and hosting them there." -- Yahoo YSlow

I interpret this to mean that I could experience performance gains if I move www.example.com/images to static.example.com/images.

Although this is easy to do, I would lose the handy ability within my content management system (Joomla/WordPress) to easily reference and link to these images.

Is it possible to use .htaccess to redirect all requests for a particular folder on www.example.com to a folder on static.example.com instead? Would this method also fool the CMS into thinking the images were located in the default locations on its own domain?

7 Answer