Question

My goal is to use Varnish to cache my static assets with my Symfony 1.4 site (http://my.perqworks.com).

I can write a VCL file that strips out cookies on all static files while leaving the user authentication cookie on the php file -- but the user authentication is failing. I cannot log into my application.

I am looking for an answer that describes how to use Varnish to cache static files while allowing my Symfony application to log in and support user authentication.

Currently I am using something like this:

if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") { unset req.http.cookie; }

Was it helpful?

Solution

A different, but perhaps better, approach would be to serve your static content from a different domain or subdomain that has no cookies set. If your website is "example.org", then instead of setting cookies for ".example.org" you would set them for "www.example.org, and put static content on "static.example.org".

As well as making your set up easier to manage, this would make the client's HTTP requests for static items smaller, which is one of the YSlow recommendations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top