How to set "Expires" of HTTP Header with VCL?

Artur sky at crucially.net
Tue Feb 10 23:53:03 CET 2009


in vcl_deliver

   C{
       char *cache = VRT_GetHdr(sp, HDR_REQ, "\016cache-control:");
       char date[40];
       int max_age;
       int want_equals = 0;
       if(cache) {
	while(*cache != '\0') {
	  if (want_equals && *cache == '=') {
	    cache++;
	    max_age = strtoul(cache, 0, 0);
	    break;
	  }

	  if (*cache == 'm' && !memcmp(cache, "max-age", 7)) {
	    cache += 7;
	    want_equals = 1;
	    continue;
	  }
	  cache++;
	}
	if (max_age) {
	  TIM_format(TIM_real() + max_age, date);
	  VRT_SetHdr(sp, HDR_RESP, "\010Expires:", date, vrt_magic_string_end);
	}
       }
     }C


On Feb 10, 2009, at 2:15 AM, David wrote:

> I want to set the "Expires" of HTTP Header in GMT format in  
> vcl_deliver with VCL.
> How to achieve that?
>
>
> 网易邮箱,中国第一大电子邮件服务商  
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-dev




More information about the varnish-dev mailing list