Important note

The EdgeRules feature is available only on Enterprise plans.

In this tutorial we’ll show you a simple way to manage caching based on the value of a request cookie.

Using the example below, we’ll prevent caching of requests with cookies named as either: “wp” or “wordpress” or “comment”.

Here’s how to set it up using EdgeRules in the MaxCDN Control Panel:

Nginx Configuration Block

location / {
		set $tmp "0";
		if ($http_cookie ~* (wp|wordpress|comment)) {                                  
			set $tmp "1";
		}
                proxy_no_cache $tmp;
}

CURL Test Without Cookie

$ curl -I gbgcl13.netdnasa2.netdna-cdn.com/
HTTP/1.1 200 OK
Date: Wed, 23 Sep 2015 19:21:43 GMT
Content-Type: text/html
Content-Length: 935
Last-Modified: Thu, 06 Aug 2015 12:32:59 GMT
Cache-Control: public, must-revalidate, proxy-revalidate
Server: NetDNA-cache/2.2
X-Cache: HIT
Accept-Ranges: bytes

CURL Test With Proper Cookie in Request

$ curl -I gbgcl13.netdnasa2.netdna-cdn.com/ -b "random=value"
HTTP/1.1 200 OK
Date: Wed, 23 Sep 2015 19:22:47 GMT
Content-Type: text/html
Content-Length: 935
Last-Modified: Thu, 06 Aug 2015 12:32:59 GMT
Cache-Control: public, must-revalidate, proxy-revalidate
Server: NetDNA-cache/2.2
X-Cache: MISS
Accept-Ranges: bytes