Hi All:
How can I caching a location/files just for specific user-agents?
I mean something like:
if ($http_user_agent ~ (googlebot|bingbot|badbot) ) {
location ~* \.(html)$ {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache cache_one;
proxy_ignore_headers Set-Cookie Cache-Control Expires;
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_cache_valid 200 304 30m;
proxy_cache_key $host$uri$is_args$args;
expires 336h;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 120;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_pass http://myapachecluster;
}
}
But it seems that it is not possible to use proxy_* directives with this structure (if/location)
Any ideas?
Thank you very much.
Regards,
How can I caching a location/files just for specific user-agents?
I mean something like:
if ($http_user_agent ~ (googlebot|bingbot|badbot) ) {
location ~* \.(html)$ {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache cache_one;
proxy_ignore_headers Set-Cookie Cache-Control Expires;
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_cache_valid 200 304 30m;
proxy_cache_key $host$uri$is_args$args;
expires 336h;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 120;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_pass http://myapachecluster;
}
}
But it seems that it is not possible to use proxy_* directives with this structure (if/location)
Any ideas?
Thank you very much.
Regards,