I am trying to make ATS cache return of my UWSGI Application which currently runs on the same machine as ATS itself.
I don't understand why ATS always forwards my requests to UWSGI and does not cache the results. I use ATS 5.1.1 on ubuntu 14.04 compiled from source and I followed a tutorial described here: http://daemonkeeper.net/735/apache-trafficserver-the-better-web-cache/
Using curl to make a test request, I always receive these diagnostics in the Via header:
uScMsSf pSeN:t cCMi p sS
WHich can be decoded with traffic_via to:
Proxy request results:
Request headers received from client: simple request (not conditional)
Result of Traffic Server cache lookup for URL: miss (a cache "MISS")
Response information received from origin server: served
Result of document write-to-cache: no cache write performed
Proxy operation result: served
Error codes (if any): no error
Operational results:
Tunnel info: no tunneling
Cache-type and cache-lookup cache result values: cache / cache miss (url not in cache)
ICP status: no icp
Parent proxy connection status: no parent proxy
Origin server connection status: connection opened successfully
Can someone help me understand, why the result is not being cached?
My remap.config:
map http://trafficserver_build:8080 http://127.0.0.1:8888
My cache.config:
url_regex=.* revalidate=10m
My storage.config (default provided):
var/trafficserver 256M
Log requests state:
/opt/ts/bin/traffic_logcat -f /opt/ts/var/log/trafficserver/squid.blog 1415307115.252 0 10.0.3.28 TCP_MISS/200 258 HEAD http://127.0.0.1:8888/ - DIRECT/127.0.0.1 text/html 1415307127.721 0 10.0.3.28 TCP_MISS/200 258 HEAD http://127.0.0.1:8888/ - DIRECT/127.0.0.1 text/html 1415307171.141 0 10.0.3.28 TCP_MISS/200 258 HEAD http://127.0.0.1:8888/ - DIRECT/127.0.0.1 text/html 1415307176.480 0 10.0.3.28 TCP_MISS/200 258 HEAD http://127.0.0.1:8888/ - DIRECT/127.0.0.1 text/html
The most likely problem is that your origin is not setting the expected HTTP headers to make the response cacheable. The relevant Traffic Server setting is proxy.config.http.cache.required_headers, and the default is quite strict in requiring an Expires or Cache-Control header in the response.
https://trafficserver.readthedocs.org/en/latest/reference/configuration/records.config.en.html#proxy-config-http-cache-required-headers
You can also force content into cache by:
proxy.config.http.cache.required_headers
to0
; andSo for example you could set cache.config to contain
dest_domain=mysite.com ttl-in-cache=10m
Combined with
required_headers
of0
, this will work even when you don't control the originFound it out... As James Peach points out I had to allow all requests to be cachable, but in addition the response must send the Vary header.