0
votes

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

3
Maybe show the headers returned by the webserver that you have put Varnish in front of?asjo

3 Answers

1
votes

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.

0
votes

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!)

0
votes

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