Re: Looking to implement "If modified since" between browser and varnish cache

Indranil Chakravorty indranilc at rediff-inc.com
Fri Oct 1 07:40:27 CEST 2010


Thanks,  I am now trying to figure out how to get the date time stamp from an object in cache, so that I could use it to compare with the IMS header of the request from browser. Any idea/ pointers? Thanks.

- Neel




On Fri, 01 Oct 2010 09:45:05 +0530 Ask Bjørn Hansen  wrote
>
>On Sep 30, 2010, at 20:06, Indranil Chakravorty wrote:
>
>> I have been mulling over the feasibility of implementing conditional requests between the client browser and varnish cache. 
>
>You are in luck - that already works. :-)
>
>And yes - all common browsers support this. You can combine a short-ish Cache-Control maxage header with a longer cache time in Varnish to get some control of how long content is cached for.
>
>
> - ask
>
>First request (get Last-Modified for the next request) ============
>
>[ask at embla ~]$ curl -svo/dev/null http://www.pool.ntp.org/en/
>* About to connect() to www.pool.ntp.org port 80 (#0)
>*  Trying 207.171.3.6... connected
>* Connected to www.pool.ntp.org (207.171.3.6) port 80 (#0)
>> GET /en/ HTTP/1.1
>> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
>> Host: www.pool.ntp.org
>> Accept: */*
>> 
>* HTTP 1.0, assume close after body
>< HTTP/1.0 200 OK
>< Server: Apache/2.2.3 (Red Hat) mod_apreq2-20051231/2.6.1 mod_perl/2.0.4 Perl/v5.8.8
>< X-UA-Compatible: IE=8
>< P3P: CP="NOI DEVo TAIo PSAo PSDo OUR IND UNI NAV", policyref="/w3c/p3p.xml"
>< Last-Modified: Fri, 01 Oct 2010 04:13:06 GMT
>< Vary: Accept-Encoding
>< Keep-Alive: timeout=30, max=100
>< Content-Type: text/html; charset=utf-8
>< Content-Length: 14214
>< Date: Fri, 01 Oct 2010 04:14:27 GMT
>< X-Varnish: 946925222 946924396
>< Age: 81
>< Via: 1.1 varnish
>* HTTP/1.0 connection set to keep alive!
>< Connection: keep-alive
>< X-Served-By: ntplax2.ntppool.net
>< X-Cache: HIT
>< X-Cache-Hits: 298
>< 
>{ [data not shown]
>* Connection #0 to host www.pool.ntp.org left intact
>* Closing connection #0
>
>
>IMS request ==============
>
>
>[ask at embla ~]$ curl -H 'If-Modified-Since: Fri, 01 Oct 2010 04:13:06 GMT' -svo/dev/null http://www.pool.ntp.org/en/
>* About to connect() to www.pool.ntp.org port 80 (#0)
>*  Trying 207.171.3.6... connected
>* Connected to www.pool.ntp.org (207.171.3.6) port 80 (#0)
>> GET /en/ HTTP/1.1
>> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
>> Host: www.pool.ntp.org
>> Accept: */*
>> If-Modified-Since: Fri, 01 Oct 2010 04:13:06 GMT
>> 
>< HTTP/1.1 304 Not Modified
>< Date: Fri, 01 Oct 2010 04:14:31 GMT
>< Via: 1.1 varnish
>< X-Varnish: 946925256
>< Last-Modified: Fri, 01 Oct 2010 04:13:06 GMT
>< Vary: Accept-Encoding
>< Connection: keep-alive
>< X-Served-By: ntplax2.ntppool.net
>< X-Cache: HIT
>< X-Cache-Hits: 313
>< 
>* Connection #0 to host www.pool.ntp.org left intact
>* Closing connection #0
>
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20101001/4974c5f0/attachment-0003.html>


More information about the varnish-dev mailing list