2016-06-10 23 views
1

所以我試圖根據找到的cookie來設置我的高速緩存條件。我使用下面的代碼,但功能不能正常工作,因爲Cookie頁面被緩存了24小時。任何人都可以看看,並讓我知道下面的代碼我的問題是什麼?高速緩存條件不工作基於WordPress的餅乾

if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") { 
     set cacheable = false;#versions less than 3 
     beresp.ttl>0 is cacheable so 0 will not be cached 
     set beresp.ttl = 0s; 
    } else { 
     set beresp.cacheable = true; 
     set beresp.ttl=300s;#cache for 24hrs 
    } 

回答

2

所以你的代碼丟失set beresp標誌使用下面的代碼,然後測試它將完美工作。

if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") { 
     set beresp.cacheable = false;#versions less than 3 
     beresp.ttl>0 is cacheable so 0 will not be cached 
     set beresp.ttl = 0s; 
    } else { 
     set beresp.cacheable = true; 
     set beresp.ttl=300s;#cache for 24hrs 
    }