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

Indranil Chakravorty indranilc at rediff-inc.com
Fri Oct 1 12:08:25 CEST 2010


If the browser sends a req for the same page again to the cache, then the "if modified since" header of the req is compared with the "date" of the object in cache. In case the cache object is not newer than the IMS header, then the cache returns 304, so that we avoid further data transfer between cache and browser. The browser in this case would simply read from its own cache. 

I have come up with this solution. My basic idea is the following addition to vcl in sub vcl_hit().
        if (req.http.If-Modified-Since && obj.http.Date) {                //if (obj.http.Date <= req.http.If-Modified-Since) {                //    error 304 "Not Modified";                //}        }
I understand I can not use "<=", so I have gone ahead and used the corresponding inline C code to convert the http headers into string using VRT_GetHdr and strprintf/scanf funcs. However, now I am trying to figure out a way to implement the VCL error using inline C. Is that possible? Thanks.


Thanks,


Neel




On Fri, 01 Oct 2010 13:13:38 +0530 Ask Bjørn Hansen  wrote
>
>On Sep 30, 2010, at 22:40, Indranil Chakravorty wrote:
>
>> 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.
>
>What are you trying to do?
>
>
> - ask
>
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20101001/ba030224/attachment-0003.html>


More information about the varnish-dev mailing list