开发者

Using Varnish in a Symfony Application?

My开发者_如何学Go 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; }


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜