GridFS Nginx检查数据是否存在
我使用(基于文件系统的)静态html文件进行缓存,出于某些原因我不喜欢这样。我想在数据库中存储缓存文件(html,图像) 现在它是这样工作的:GridFS Nginx检查数据是否存在,nginx,gridfs,Nginx,Gridfs,我使用(基于文件系统的)静态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 bre
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、AmazonS3、Mysql或其他任何工具进行检查,这是可能的吗
非常感谢
答案是
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;
}
您可以使用该模块直接从Nginx提供GridFS文件,然后将这些文件代理到另一台服务器。这里还有一个很好的答案