2011-11-08 41 views
1

我使用(基于文件系统)的静态html文件进行缓存,出于某些原因,我不喜欢这样。我想在数据库中存储缓存文件(html,图像)。GridFS Nginx检查数据是否存在

现在的工作就像是:

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或任何ALSE?

非常感谢

,答案是

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;     
} 
+0

还有一个好的答案在这里https://github.com/mdirolf/nginx-gridfs/issues/10 – derevo

回答