how storing objects for a given time, regardless of expire info from back-end?
Dirk Taggesell
dirk.taggesell at proximic.com
Tue Apr 13 17:03:28 CEST 2010
On 12.04.10 18:22, Rob S wrote:
> In vcl_fetch, pop:
> set obj.ttl = 7200s;
> and everything will be cached for 2hrs.
>
> If that doesn't work, then can you post the full VCL you're using.
The config compiler complains when trying to start varnish.
My initial and working config is this:
>> backend default {
>> .host = "backend.example.com";
>> .port = "80";
>> }
nothing else, neither a vcl_fetch part, and I start the varnish with:
varnishd -a 0.0.0.0:80 -f etc/varnish/myconf.vcl -F
What I want is to fetch items from the back-end and not contacting the
back-end again for the particular item for the next X hours, instead
caching and delivering it. Adding a custom expires header for delivered
contents is the second feature. That's pretty much it.
With the very simple config like above, varnish works, but contacts the
back-end again every time an item is fetched (may be for an
if-modified-since request).
But just adding a vcl_fetch subroutine to the minimal config appears not
to be sufficient. This:
sub vcl_fetch {
set obj.ttl = 7200s;
return(deliver);
}
Throws an error when i try to start varnish:
Message from VCC-compiler:
Variable 'obj.ttl' not accessible in method 'vcl_fetch'.
At: (input Line 13 Pos 7)
set obj.ttl = 7200s;
------#######---------
Running VCC-compiler failed, exit 1
VCL compilation failed
I also uncommented everything in the standard vcl file which is claimed
to replicate the default behaviour. That works, but just inserting the
sub vcl_fetch above doesn't work.
It appears one cannot simply take a minimal config and add rules. There
seems to be missing some tutorial explaining the concept of varnish
config files. If I ever come to understand it, maybe I'll write
something like a tut.
--
Dirk Taggesell
More information about the varnish-misc
mailing list