2017-07-06 57 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; 
}