Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I followed the tutorial The Perfect Server - Ubuntu 11.10 [ISPConfig 3] here. I'm running an Ubuntu 11.04 (Natty Narwhal) server with 1024 RAM on Rackspace. I've gone through and updated to ISPConfig 3.0.4. Everything has been working great up to now when I decided to try and install Varnish. Initially I did an install of Varnish by issuing:

apt-get update
apt-get upgrade
apt-get install varnish

Apparently the version that was installed was Varnish 2.x so I went back and added the repositories for packages provided by varnish-cache.org

curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -
echo "deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-3.0" >> /etc/apt/sources.list
apt-get update
apt-get install varnish

This updated my version of Varnish to 3.0.2

I then proceeded to make the following changes:

vim /etc/default/varnish
change DAEMON_OPTS to port 80:
vim /etc/apache2/ports.conf
NameVirtualHost *:8000
Listen 8000
vim /etc/apache2/sites-available/default
<VirtualHost *:8000>
vim /etc/apache2/sites-available/ispconfig.vhost
Listen 8080
NameVirtualHost *:8080
<VirtualHost _default_:8080>

I then proceeded to set my other vhosts to use 8000 (the apache2 port)

so with all this set I reset both Apache2 and Varnish to test. I used Firebug in Firefox 11.0

The output from what I see doesn't seem to indicate that Varnish is working completely correct:

enter image description here

First of all I see: X-Varnish 1644834493 but I've heard that unless you have two timestamps side by side than it's probably not working correctly so for example I was thinking I might see something like:

X-Varnish 1644834493 1644837493

Also if I noticed this in the output which seems to be inconstant:

X-Drupal-Cache MISS

There are times when it will say HIT as well....

So the question here that I have is I think Varnish is partially working, however, why don't I see two timestamps on X-Varnish like I'm thinking I should and does the output of the screenshot I have look correct? If Varnish isn't working can someone tell me what I might being doing wrong?

Thanks in advance.

share|improve this question
    
natty narwhal is not a great choice. It's an unsupported release now, although not at the time you asked the question. wiki.ubuntu.com/Releases has the information on what's under support and till when. I'd stick with LTS releases personally, especially for a server. –  Richard Salts Jan 14 at 7:00

1 Answer 1

Regarding the X-Varnish header: The first ID is an internal request id, so this should change every time. If there is a second value, than Varnish provides you a cached object. The second ID is the internal cache ID of this object.

Regarding your assumption you are right, that Varnish hasn't delivered cached content. You can additionally check the Age header which tells us that the content is 0 seconds old (so it's fresh). The allowed maximum age of the response is set in the Cache-Control header: 180 seconds in your case. This is not really long but enough for further testing.

Please check the response headers for following actions (take care to enable caching in your browser - for Firefox you can enable/disable it via the Web-Developer bar):

  1. after a first fresh load of your test page click reload in your browser
  2. after a first fresh load of your test page click into your browsers address bar and press enter

The browser handles two ways of fetching content differently (for details check your request headers). By pressing the reload button (or disable caching via Web-Developer bar) your browser sends Cache-Control headers to force delivery of fresh content and Varnish honors these. By loading the same URL a second time (e.g. clicking on links, using forward and backward buttons, pressing enter in the browsers address bar ...) your browser does not send out these Cache-Control headers and Varnish is able to deliver cached content.

If you want to cache that behavior and you'd like to force use of cached content you can optimize Varnish's configuration. But this is another story.

Regarding your X-Drupal-Cache header: This header is set by the back-end Varnish is using. This tells you that Varnish has used fresh content for its cache or response.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.