Scot Robinson
Scot Robinson

Reputation: 41

Trouble getting Varnish to cache

We are hosting a major tennis tournament website and are trying to use Varnish on Rackspace to help with the traffic we anticipate. We have hired too systems consultants to help install Varnish on our cloud servers, but for whatever reason they are not able to get Varnish to work with our scripts. A typical script can be found here:

162.242.140.232/scoring/DemoGetOOP.php

There is nothing special about this script. It doesn't have any special caching commands in the headers and doesn't use session control. You can see by the date/time at the bottom that we have for testing purposes, that the page is not being cached. We set up a timer page which is cached:

162.242.140.232/scoring/timer.php

and also an info.php page at:

162.242.140.232/scoring/info.php

What's odd, is that if you first go to the timer.php, you can see it's cached for 10 seconds. However, if you then run our DemoGetOOP.php script and go back to timer.php, it's no longer cached. We have to clear the cache again or open up a private browser window to see the caching.

if (req.url ~ "^/scoring/DemoGetOOP.php") and

if (req.url ~ "/scoring/DemoGetOOP.php")

any help would be greatly appreciated!

Upvotes: 0

Views: 86

Answers (2)

Arjan
Arjan

Reputation: 416

First of all i would start with setting correct cache headers, i would prefer the Cache-Control header. The DemoGetOOP script also send a cookie, whereby Varnish will pass caching.

I would suggest to check the varnishlog which will give you a clear insight in why Varnish decides to cache or not.

Upvotes: 1

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42899

They seem to be working fine to me, first link has a ttl of 120 seconds and the second link has a ttl of 10 seconds and both are working just fine.

I'd say always double check the cookies when things seem to be not workning.

Upvotes: 0

Related Questions