marcelo.delta
marcelo.delta

Reputation: 3082

Varnish 4 Cache does not cache dynamic page

It is possible cache of dynamic pages, especially the home page?

For plan to reduce access to the database .

I can do static file cache. perfect.

Response headers

Accept-Ranges:bytes

Age:0

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Connection:keep-alive

Content-Type:text/html; charset=utf-8

Date:Tue, 09 Dec 2014 17:07:13 GMT

Expires:Thu, 19 Nov 1981 08:52:00 GMT

Pragma:no-cache

Transfer-Encoding:chunked

Via:1.1 varnish-v4

x-Cache:uncached

X-Varnish:295421

File default vcl: http://notepad.cc/vaokodde9

Upvotes: 0

Views: 1311

Answers (3)

marcelo.delta
marcelo.delta

Reputation: 3082

Thank you all . I managed to solve the problem by studying a little about the functioning of the cookie in the varnish .

Upvotes: 0

Jorge Nerín
Jorge Nerín

Reputation: 766

Your backend is screamming it doesn't want anyone to cache the page:

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache

It's setting all the Cache-Control headers to disallow cache, it's setting an Expires header in the past (way back), and a Pragma: no-cache. You either have to fix the backend to send headers that allow caching, or if you are sure that you won't break anything start to workaround this headers in vcl.

I would choose the first option, and work the Cookies issue later.

Upvotes: 1

asjo
asjo

Reputation: 3194

I think Varnish by default does not cache pages with Cookies. Maybe that is your problem (it looks like you have a PHPSESSID and some other stuff)?

See the Varnish documentation: https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies

Try configuring your webserver to not set any cookies, or configure Varnish to ignore them (note that that may not make sense, and break your website!)

Upvotes: 0

Related Questions