我使用(基于文件系统的)静态 html 文件进行缓存,出于某些原因,我不喜欢这样。我想在数据库中存储缓存文件(html、图像)。
现在它像这样工作:
if nginx can get cache:
return cache to user
else
proxy_pass request to backend server
在我的 Nginx 配置文件中看起来像这样
if (-f $cache_dir_prefix/$query) {
rewrite (.*) $query break;
}
if (!-f $cache_dir_prefix/$query) {
proxy_pass http://lionyzer;
break;
}
是否可以使用 GridFS 或 Amazon S3 或 Mysql 或其他任何东西进行 IF 检查?
非常感谢
答案是
location /assets/ {
gridfs assets field=filename type=string;
mongo 127.0.0.1:27017;
error_page 404 = @scale;
}
location @scale {
include fastcgi.conf;
fastcgi_pass unix:/tmp/php-fpm;
fastcgi_param SCRIPT_FILENAME scaleme.php;
}