Search code examples
varnishvarnish-vclfastly

Specify expiration date when setting cookies


I want to specify an expiration date when setting cookies in VCL. I currently have something like this:

add resp.http.Set-Cookie = "language=" + req.http.X-Language + "; path=/";

I know that I will have to add something like this:

Expires=Thu, 01 Jan 1970 00:00:00 GMT

Is there a built-in function in Varnish that will allow me to dynamically set the expiration date to anything in the future? I've been looking at their docs but no luck so far.

Thank you very much in advance.

-Angel


Solution

  • UPDATE - Working solution:

    Not sure if this syntax is specific to Fastly but I got it working using : time.add(now,1d) :

    add resp.http.Set-Cookie = "language=" + req.http.X-Language + ";expires="+ time.add(now,1d) +"; path=/";