Caching issue
Adrian Otto
aotto at mosso.com
Fri Mar 7 22:54:58 CET 2008
Shain,
I can't say for certain without looking at it myself, but I wonder if
when you request the URL from the second machine using firefox you
are actually doing a "refresh" that's setting a Cache-Control header
that's forcing varnish to consult the origin server. I suggest
connecting to your varnish with "varnishlog" and watching the headers
that each client sends varnish. If you see headers like this:
13 RxHeader c Pragma: no-cache
13 RxHeader c Cache-Control: no-cache
Then you know that's what's happening. In general, it sounds like you
are looking for an "off-line" mode where the cache server simply
serves stale content if an origin server can not be reached. If that
feature is present in varnish, I'm not aware of it.
Adrian
On Mar 7, 2008, at 1:10 PM, Shain Miley wrote:
> Hello all,
> First let me say thanks to everyone for taking time to work on this
> project...I am still in the testing phase, however if all goes well
> Varnish is going to come in quite handy.
>
> So here is my problem:
>
> I would like to use varnish to cache urls for say a period of 30
> minutes. The caching seems fine as long as I use the same browser to
> request the url. But I am looking for a stop gap solution at this
> time
> so in the event that the web server becomes unavailable....varnish can
> serve the docs for a little while, so we can get things back in order.
> Anyway..as it stands right now..I can request a url from wget or
> GET or
> firefox... and turn off the webserver and I can refresh the page
> and all
> is well.
>
> What I cannot do...is request a url using GET on one machine..then
> stop
> the webserver and request that same url from firefox (different
> machine)
> and get a valid page...I get a 503 error...Here is the vcl.conf file
> (which I took most of from the web) I am using:
>
> Any help would be great!
>
> Thanks,
>
> Shain
>
> sub vcl_recv {
> if (req.request != "GET" && req.request != "HEAD") {
> # PURGE request if zope asks nicely
> if (req.request == "PURGE") {
> if (!client.ip ~ purge) {
> error 405 "Not allowed.";
> }
> lookup;
> }
> pipe;
> }
> if (req.http.Expect) {
> pipe;
> }
>
> if (req.http.Authenticate || req.http.Authorization) {
> pass;
> }
>
> # We only care about the "__ac.*" cookies, used for
> authentication
> if (req.http.Cookie && req.http.Cookie ~
> "__ac(|_(name|password|persistent))=") {
> pass;
> }
>
> # File type that we will always cache
> if (req.request == "GET" && req.url ~
> "\.(html|php|gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|
> swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|
> sxw|zip|gz|bz2|tgz|tar)$")
> {
> lookup;
> }
>
> if (req.request == "POST") {
> pipe;
> }
>
> # force lookup even when cookies are present
> if (req.request == "GET" && req.http.cookie) {
> lookup;
> }
> lookup;
> }
>
> sub vcl_fetch {
>
> if (obj.ttl < 1800) {
> set obj.ttl = 1800s;
> }
> }
>
> # Do the PURGE thing
> sub vcl_hit {
> if (req.request == "PURGE") {
> set obj.ttl = 0s;
> error 200 "Purged";
> }
> }
>
> sub vcl_miss {
> if (req.request == "PURGE") {
> error 404 "Not in cache";
> }
> }
>
>
>
> _______________________________________________
> 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