【发布时间】:2017-02-10 07:12:03
【问题描述】:
我有一个写入缓存目录的图像服务器(目前它只是在 url 请求中使用相同的路径)。我已经确认在初始请求(即缓存中没有任何内容)中写入了一个新文件,但是在后续请求中,try_files 没有成功找到该文件。
我的nginx.conf 是:
http {
server {
listen 8080;
# serve tiles if not in the cache
location @image_server {
content_by_lua_file "/Users/tim/work/chickpea/serve_image.lua";
}
# capture tile request e.g. /tile/l8/091080/rgb/20160924/10/938/597.jpg
# regex named capture groups for each param
location ~ ^/tile/(?<layer>[^/]+)/(?<pathrow>[^/]+)/(?<type>[^/]+)/(?<date>[^/]+)/(?<z>[^/]+)/(?<x>[^/]+)/(?<y>[^.]+) {
root cache;
set $cachepath "cache/$layer/$pathrow/$type/$date/$z/$x/$y.jpg";
try_files $cachepath @image_server;
add_header X-Static hit;
}
..
我已确认应/tile/l8/091080/rgb/20160924/10/938/597.jpg 的请求,$cachepath 为cache/l8/091080/rgb/20160924/10/938/597.jpg,并且597.jpg 位于正确的路径中。我已经尝试了一个有和没有前导 cache/ 的 $cachepath ,但似乎都不起作用。
【问题讨论】: