2016-06-10 66 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 
    }