I use (File System Based) static html files for caching, for some reasons i don like this. I want store cache files (html, images) in database.
Now it work like that:
if nginx can get cache:
return cache to user
else
proxy_pass request to backend server
It looks like this in my Nginx config file
if (-f $cache_dir_prefix/$query) {
rewrite (.*) $query break;
}
if (!-f $cache_dir_prefix/$query) {
proxy_pass http://lionyzer;
break;
}
It’s posible to do IF check with GridFS Or Amazon S3 or Mysql or anything alse?
Thanks alot
AND THE ANSWER IS
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;
}
You can use the
nginx-gridfsmodule to serve GridFS files directly from Nginx, and then catch a 404 for files not found and proxy those to the other server.