2017-07-06 58 views
0

我有一个WordPress安装与Woocommerce一起运行,它需要GET请求add_to_cart才能让用户添加项目到购物车。FastCGI缓存键,同时忽略GET请求,但允许某些GET请求绕过缓存

我的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等任何帮助将是非常赞赏

UPDATE

我曾尝试使用下面的服务器块

if ($arg_name ~* "(add-to-cart|remove-item)") { 
     set $no_cache 1; 
} 

服务器仍然忽略这一点并提供缓存文件。

通过添加在检查.*add-to-cart.*用于请求NOW

回答

0

到底解决解决。

# 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; 
}