아무것도 캐싱하지 않는 오징어 프록시

아무것도 캐싱하지 않는 오징어 프록시

오징어.conf:

http_access allow all

# Squid normally listens to port 3128
http_port 3128 accel defaultsite=localhost no-vhost

cache_peer localhost parent 80 0 no-query originserver name=myAccel
cache_peer_access myAccel allow all

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /usr/local/var/cache/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /usr/local/var/cache/squid

Homebrew를 통해 OSX에 설치된 Squid 3.2.9

localhost: ~ $ squid -v
Squid Cache: Version 3.2.9
configure options:  '--disable-debug' '--disable-dependency-tracking' '--prefix=/usr/local/Cellar/squid/3.2.9' '--localstatedir=/usr/local/var' 'CC=cc' 'CXX=c++' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig'

오징어를 시작했어요squid -f squid.conf -d 2 -N

업스트림은 유효한 Cache-Control 헤더를 반환합니다. Google Chrome 26의 페이지를 방문하고 Chrome 개발자 도구를 확인하여 이 헤더가 올바른지 확인했습니다.

localhost: ~ $ curl -s -o /dev/null --dump-header /dev/stdout  http://localhost/test.php
HTTP/1.1 200 OK
Date: Tue, 16 Apr 2013 21:29:33 GMT
Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r
X-Powered-By: PHP/5.3.15
Cache-Control: max-age=60, public
Content-Length: 16
Content-Type: text/html
X-Pad: avoid browser bug

하지만 Squid 역방향 프록시를 통해 페이지를 쿼리하면 항상 캐시 누락이 발생합니다.

localhost: ~ $ curl -s -o /dev/null --dump-header /dev/stdout  http://localhost:3128/test.php
HTTP/1.1 200 OK
Date: Tue, 16 Apr 2013 21:29:34 GMT
Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r
X-Powered-By: PHP/5.3.15
Cache-Control: max-age=60, public
Content-Length: 16
Content-Type: text/html
X-Cache: MISS from localhost
Via: 1.1 localhost (squid/3.2.9)
Connection: keep-alive

localhost: ~ $ curl -s -o /dev/null --dump-header /dev/stdout  http://localhost:3128/test.php
HTTP/1.1 200 OK
Date: Tue, 16 Apr 2013 21:29:38 GMT
Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r
X-Powered-By: PHP/5.3.15
Cache-Control: max-age=60, public
Content-Length: 16
Content-Type: text/html
X-Cache: MISS from localhost
Via: 1.1 localhost (squid/3.2.9)
Connection: keep-alive

내 구성에 어떤 문제가 있나요?

답변1

아, 젠장, 알아냈어.

Squid는 1분 미만이거나 EQUAL TO인 캐시 헤더를 무시합니다. 따라서 max-age=60은 무시되지만 max-age=61은 매력처럼 작동합니다.

<?php
Header('Cache-Control: max-age=61');

?><html>hi</html>

관련 정보