Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does anyone know a way to add expires header to a response in Varnish, like Apache does? Using Apache directives you can set expire headers and set how much time from now they will expire i.e. 1 month 15 days 2 hours, like this:

ExpiresByType text/html "access plus 1 month 15 days 2 hours"
ExpiresByType image/gif "modification plus 5 hours 3 minutes" 
share|improve this question

1 Answer 1

You can not do that with Varnish. You can define an "Expires" header like set beresp.http.Expires = XXXX in vcl_fetch. But you can not base the value of your header on an mtime/atime because Varnish never touches files sent by Apache and so can not get access to you mtime/atime.

You could actually send two extra headers from your origin server to inform Varnish about the resource's mtime/atime, something like X-Mtime: 1234 an X-Atime: 1234 so you can fetch them from Varnish with beresp.http.X-Mtime or beresp.http.X-Atime but this looks really overkill to me.

Furthermore you would need Apache/Nginx to send those custom headers for each request and to be honnest I do not know if that is possible to get such informations.

'hope that helps :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.