Mailing List Archive

Newbie : Static content caching
Hello all,

I have been using Varnish with its "default configuration" for quite
sometime now.
Absolutely nothing has changed except for the backed servers port number
(set to 8000).

Needless to say that it has been performing brilliantly and has reduced
the load on our webservers considerably.

Just noticed something strange though.
Before i explain further, please let me clarify that i am not an expert
in caching by any standard, so this happens to be more of a newbie question.

I am running varnish and the backend apache on the same server.
The backend listens on the loopback address while varnish listens on the
interface facing the load balancer.

If i request, say for example, a static jpeg, i assume that the first
request will be served by the webserver via varnish, and all later
requests would be served by varnish, without asking for it from the
webserver, that is till the object exceeds its lifetime in the cache.

What i observe is this:
the request for the jpeg is sent to the webserver everytime, the
webserver send the entire content to varnish, and varnish sends a 304
Not Modified to the client browser.

Is this the expected behaviour?
Do i need to do some VCL'ing to get it work the way i expect?

Any help or pointers will be very much appreciated.

Thank you.
Newbie : Static content caching [ In reply to ]
Hello all,
Please accept my apologies for posting this without "complete"
understanding about varnish.

The reason for the static content not being cached was "cookies".
Everything is well and good after a slight tinkering of the
configuration file.

I, again, apologies for not being responsible enough before posting.
Just that, in this case, the light flickered, almost immediately after i
hit the send button.

Thank you.

Anup Shukla wrote:
> Hello all,
>
> I have been using Varnish with its "default configuration" for quite
> sometime now.
> Absolutely nothing has changed except for the backed servers port number
> (set to 8000).
>
> Needless to say that it has been performing brilliantly and has reduced
> the load on our webservers considerably.
>
> Just noticed something strange though.
> Before i explain further, please let me clarify that i am not an expert
> in caching by any standard, so this happens to be more of a newbie question.
>
> I am running varnish and the backend apache on the same server.
> The backend listens on the loopback address while varnish listens on the
> interface facing the load balancer.
>
> If i request, say for example, a static jpeg, i assume that the first
> request will be served by the webserver via varnish, and all later
> requests would be served by varnish, without asking for it from the
> webserver, that is till the object exceeds its lifetime in the cache.
>
> What i observe is this:
> the request for the jpeg is sent to the webserver everytime, the
> webserver send the entire content to varnish, and varnish sends a 304
> Not Modified to the client browser.
>
> Is this the expected behaviour?
> Do i need to do some VCL'ing to get it work the way i expect?
>
> Any help or pointers will be very much appreciated.
>
> Thank you.
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
Newbie : Static content caching [ In reply to ]
Anup Shukla <anup at iamcool.net> writes:
> If i request, say for example, a static jpeg, i assume that the first
> request will be served by the webserver via varnish, and all later
> requests would be served by varnish, without asking for it from the
> webserver, that is till the object exceeds its lifetime in the cache.
>
> What i observe is this: the request for the jpeg is sent to the
> webserver everytime, the webserver send the entire content to varnish,
> and varnish sends a 304 Not Modified to the client browser.

Most likely, the backend does not set an expiry time on the requested
image, so Varnish uses the default TTL (normally 120s).

Another possibility is that your site uses cookies; by default, Varnish
will not serve requests that come with a cookie from its cache.

I can provide a more detailed (and correct) explanation if you send me a
raw varnish log off-list.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
Newbie : Static content caching [ In reply to ]
Hi Dag-Erling Sm?rgrav,

Thank you for your response.
It was the cookies.
Forcing varnish to cache requests even if cookies are present does the
trick.

Thank you again.

Dag-Erling Sm?rgrav wrote:
> Anup Shukla <anup at iamcool.net> writes:
>> If i request, say for example, a static jpeg, i assume that the first
>> request will be served by the webserver via varnish, and all later
>> requests would be served by varnish, without asking for it from the
>> webserver, that is till the object exceeds its lifetime in the cache.
>>
>> What i observe is this: the request for the jpeg is sent to the
>> webserver everytime, the webserver send the entire content to varnish,
>> and varnish sends a 304 Not Modified to the client browser.
>
> Most likely, the backend does not set an expiry time on the requested
> image, so Varnish uses the default TTL (normally 120s).
>
> Another possibility is that your site uses cookies; by default, Varnish
> will not serve requests that come with a cookie from its cache.
>
> I can provide a more detailed (and correct) explanation if you send me a
> raw varnish log off-list.
>
> DES