mod_cache doesn't cash?

5 views
Skip to first unread message

Alesha Vlasov

unread,
Nov 16, 2008, 1:49:38 PM11/16/08
to mod_cache
Hi.

I use lighttpd 1.4.19 and mod_cache 1.6.0.

My settings:

server.port = 81
server.modules = (
"mod_status",
"mod_proxy",
"mod_accesslog",
"mod_cache"
)

cache.debug = "enable"
cache.bases = ("/tmp/.lighttpd")
cache.support-queries = "enable"
cache.refresh-pattern = (
"\.(?i)(js|css|xml)$" => "5", # update js/css/xml every 5 minutes
and on refresh requests
"\.(?i)(htm|html|shtml)$" => "5", # update html/htm/shtml every 5
minutes and on refresh requests
"\.(?i)(jpg|bmp|jpeg|gif|png)$" => "10", # 5 munutes
".(?i)php$" => "2" # update php request every 5 minutes
)

proxy.server = ( "/" =>
( (
"host" => "123.123.123.123",
"port" => 80
) )
)
proxy.worked-with-mod-cache = "enable"

I check the mod_cache work the following way:
# wget -S http://aaa:81/ruska2.jpg
--21:43:49-- http://aaa:81/ruska2.jpg
=> `ruska2.jpg'
Resolving aaa... 123.123.123.123
Connecting to aaa|123.123.123.123|:81... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Connection: keep-alive
Date: Sun, 16 Nov 2008 18:43:49 GMT
Server: Apache/2.2.9 (Unix) PHP/5.2.6
Last-Modified: Tue, 28 Oct 2008 12:56:51 GMT
ETag: "2051e5b7-2ce96-45a4fc7fceac0"
Accept-Ranges: bytes
Content-Length: 183958
Cache-Control: max-age=399
Expires: Sun, 16 Nov 2008 18:50:28 GMT
Content-Type: image/jpeg
X-Cache: HIT
Length: 183,958 (180K) [image/jpeg]

100%[============================================================>]
183,958 --.--K/s

21:43:49 (9.85 MB/s) - `ruska2.jpg' saved [183958/183958]

In lighttpd log:
233.233.233.233 aaa:81 - [16/Nov/2008:21:43:49 +0300] "GET /ruska2.jpg
HTTP/1.0" 200 183958 "-" "Wget/1.10.2"

There is also a record in Apache log file:
123.123.123.123 - - [16/Nov/2008:21:43:49 +0300] "GET /ruska2.jpg HTTP/
1.0" 200 183958 "-" "Wget/1.10.2"

Why does lighttpd send request to backend and gets file from Apache
despite the fact that files are in cache
# ls -l /tmp/.lighttpd/aaa\:81/ruska2.jpg
-rw-r--r-- 1 www daemon 183958 Oct 28 15:56 /tmp/.lighttpd/aaa:81/
ruska2.jpg
?

(error log lighttpd is empty)

Hongyu

unread,
Nov 16, 2008, 8:16:23 PM11/16/08
to mod_...@googlegroups.com
this line of cache.refresh-pattern


  "\.(?i)(jpg|bmp|jpeg|gif|png)$ " => "10", # 5 munutes

set jpg/bmp/jpeg cache for only 10 minutes, so lighttpd has to check backend server whether it's expired.


Alesha Vlasov

unread,
Nov 17, 2008, 10:48:14 AM11/17/08
to mod_cache
Hongyu:
> this line of cache.refresh-pattern
>
> "\.(?i)(jpg|bmp|jpeg|gif|png)$ " => "10", # 5 munutes

It is already set at 10 mins in my config.

> set jpg/bmp/jpeg cache for only 10 minutes, so lighttpd has to check backend
> server whether it's expired.

I didn't understand, if I want to check whether the file in cache has
expired or not I should make GET request to backend?

Hongyu

unread,
Nov 17, 2008, 10:53:14 AM11/17/08
to mod_...@googlegroups.com
That's the difference between mod_cache with other cache servers(such as squid). mod_cache doesn't provide final request handle for http, it depends on other modules such as mod_proxy and mod_staticfile.

When modcache wants to check whether content is expired, it passes request to mod_proxy and parses response of mod_proxy to update local cache file.

On Mon, Nov 17, 2008 at 11:48 PM, Alesha Vlasov <ren...@renton.name> wrote:

Hongyu:

Alesha Vlasov

unread,
Nov 17, 2008, 11:57:05 AM11/17/08
to mod_cache
Thank you. Now it's clear.
But why should I check it everytime? If it is only 10 mins after
adding file to cache?

Hongyu:
Reply all
Reply to author
Forward
0 new messages