Varnish with Wordpress
Simon Lyall
simon at darkmere.gen.nz
Tue Jun 28 05:59:40 CEST 2011
On Mon, 27 Jun 2011, kevin wrote:
> Separate cache times for media might avoid that issue :
>
> if (req.url ~ ".(gif|jpg|jpeg|png|css|js|java|fla|swf)$") {
> set beresp.http.cache-control = "public, max-age=2592000";
> C{
> #include <time.h>
> static char timebuf[30];
> char *format = {"%a, %d %b %Y %H:%M:%S GMT"};
> struct tm timestruct;
> time_t now;
> time(&now);
> now+=2592000;
> gmtime_r(&now, ×truct);
> strftime(timebuf, 30, format, ×truct);
> VRT_SetHdr(sp, HDR_BERESP, "\010Expires:", timebuf,
> vrt_magic_string_end);
> }C
> set beresp.ttl = 12h;
> return(deliver);
> }
Not sure you need all that trouble to generate the expires header. I
copied the example of this page:
https://www.varnish-cache.org/trac/wiki/VCLExampleLongerCaching
so I only end up with a Last-Modified, Cache-Control and Date.
Server: Apache
Last-Modified: Wed, 06 Jun 2007 21:12:47 GMT
Cache-Control: max-age=32832000
Content-Type: text/html; charset=UTF-8
Content-Length: 63
Accept-Ranges: bytes
Date: Tue, 28 Jun 2011 03:56:20 GMT
Connection: keep-alive
Cache-Info: Object-Age=510885, hits=247477, Cache-Host=moth, Backend-Host=apn207, healthy=yes
--
Simon Lyall | Very Busy | Web: http://www.darkmere.gen.nz/
"To stay awake all night adds a day to your life" - Stilgar | eMT.
More information about the varnish-misc
mailing list