[squid-users] Reverse-Proxy/Cache for one backend webserver

From: Frank Helmschrott <fhelmschrott_at_gmail.com>
Date: Thu, 12 Jun 2008 10:01:05 +0200

Hi all,

i'm rather new to squid so sorry if some of my questions sound a bit
dumb. I already read a lot about reverse proxy/caching with squid and
i'm sure squid is the right thing for my project.

My setup is a 2-server setup with one server with squid installed
beeing the proxy-server for a dynamic website delivered from server 2
using apache/php/mysql. The Website on server 2 is a news-style
website. Therefore the content isn't too dynamic making not only
graphics and css files cachable but also the news items itself.

For testing purposes i setup a small script and some dns stuff so that

dyn.testdomain.com resolves to the public ip of server 2
stat.testdomain.com resolves to the public ip of server 1 (squid)

The test script just contains a little php for the header (to set
expire, modified and stuff) and an output of the actual time to let me
see if it's fetched from server 2 or the cache.

After setting up everything i found to be important the basic proxy
stuff works apart from the caching and expiry stuff. It seems like
squid is fetching the original content whenever i reload the browser.
I've also already set refresh_pattern to match php files and override
the expiry set in the script and ignore reloads but unfortunately this
doesn't help. Here's what my squid conf looks like:
(below you'll find the php script i use for testing)

---
cache_mgr my_at_email.com
cache_dir ufs /var/cache/squid 4096 16 256
cache_mem 2048 MB
collapsed_forwarding on
minimum_expiry_time 120 seconds
http_port 127.0.0.1:80 vhost vport
cache_peer 127.0.0.2 parent 80 0 originserver default
acl all src 0.0.0.0/0.0.0.0
acl QUERY urlpath_regex ^/admin \?
acl our_sites dstdomain .testdomain.com
http_access allow our_sites
no_cache allow QUERY
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
http_access allow manager localhost
cachemgr_passwd comet74 all
via on
header_access Via allow all
header_access Age deny all
header_access X-Cache deny all
refresh_pattern -i \.jpg$ 120 90% 240 override-expire override-lastmod
reload-into-ims ignore-reload
refresh_pattern -i \.jpeg$ 120 90% 240 override-expire
override-lastmod ignore-reload reload-into-ims
refresh_pattern -i \.gif$ 120 90% 240 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.png$ 120 90% 240 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.swf$ 120 90% 240 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.flv$ 120 90% 240 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.js$ 10 90% 20 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.css$ 10 90% 20 override-expire override-lastmod
ignore-reload reload-into-ims
refresh_pattern -i \.php$ 10 90% 720 override-expire override-lastmod
ignore-reload ignore-no-cache
---
<?php
//expire time in minutes
$expire = 3;
$exp_gmt = gmdate("D, d M Y H:i:s", time() + $expire * 60) ." GMT";
$mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) ." GMT";
// HTTP 1.0
header("Expires: " . $exp_gmt);
header("Last-Modified: " . $mod_gmt);
// HTTP 1.1
header("Cache-Control: public, max-age=" . $expire * 60);
//header("Pragma: ");
?>
<?php
$i = 1;
while ($i <= 3):
    echo $i++ . "<br />";
endwhile;
echo "miss at " . date('H:i:s');
?>
Any help is appreciated.
-- 
Frank
Received on Thu Jun 12 2008 - 08:01:09 MDT

This archive was generated by hypermail 2.2.0 : Thu Jun 12 2008 - 12:00:04 MDT