我在Woocommerce上运行WordPress安装,需要GET请求add_to_cart
才能运行,以便用户将商品添加到购物车。
我有类似的FastCGI缓存密钥 How to set fastcgi_cache_key using original $request_uri without $args?
# Map request_path var without query strings
map $request_uri $request_path {
~(?<captured_path>[^?]*) $captured_path;
}
# FastCGI Cache
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_path$cookie_aelia_cs_selected_currency";
有没有办法绕过这些请求的FastCGI,以及NGINX只为该页面提供服务?
我对NGINX很新,因此非常感谢任何帮助
更新
我尝试在服务器块中使用以下内容
if ($arg_name ~* "(add-to-cart|remove-item)") {
set $no_cache 1;
}
服务器仍然忽略这一点并提供缓存文件。
现已解决
答案 0 :(得分:0)
最后通过在检查请求中添加.*add-to-cart.*
来解决。
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml|.*add-to-cart.*") {
set $no_cache 1;
}