Install and configure varnish to run in front of Apache - A quick google turned up this tutorial, which will get you going...
http://code.tutsplus.com/tutorials/opti ... -cms-21136In addition to that, you might want to add the following code to your default.vcl and restart varnish.
In "sub vcl_recv" look for the section with req.request != "GET" and immediately underneath it add the code below - I've included the code your'e looking for for reference (don't duplicate it).
Code:
if (req.request != "GET" && req.request != "HEAD") {
/* We only deal with GET and HEAD by default */
return (pass);
}
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$"
|| req.url ~ "\.(css|js)\?[a-z]*=[0-9]*$") {
unset req.http.cookie;
}This will strip cookies from images and css - you really don't need cookies and it stops varnish from caching the static files.
Then in "sub vcl_fetch" add this right at the very beginning:
Code:
if(req.url ~"\.(png|gif|jpg|swf|css|js)$" ||
req.url ~"\.(css|js)\?[a-z]*=[0-9]*$") {
unset beresp.http.set-cookie;
set beresp.ttl = 180s;
set beresp.http.X-Cache = "HIT";
return (deliver);
}
This will remove the cookie from the response to the user's browser, set a TTL of 180s (so all your images / css / js only get loaded into memory every 2 minutes), and set an extra cache header so you can check that its working.
Hopefully that helps.
J.