Expand my Community achievements bar.

SOLVED

How to cache json response in diaptcher for content as service in aem 6.5

Avatar

Level 9

I want to cache json response in dispatcher for content as service in aem 6.5. For example, I want to cache http://localhost:4503/content/we-retail/us/en/men/jcr:content/root/text.model.json. the cache works here perfectly but when if author make a content change at page level, we would want to invalidate the cache for above /content/we-retail/us/en/men/jcr:content/root/text.model.json and fetch the content from publish and get cached. Is there any way make it work at node level ?

 

As per the design it works fine if we make any change at page level. Can we make the same behavior at node or component level (in this it is text component)

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi @Mario248 ,
If your flush agent is working properly, cache for http://localhost:4503/content/we-retail/us/en/men/jcr:content/root/text.model.json should be invalidated as soon as you activate page http://localhost:4503/content/we-retail/us/en/men.html If it is not happening please check  /invalidate section in your farm file and allow *.json. After adding this rule cache invalidation should work as expected. Please add rules as per your project. 

/invalidate {
	/0000 {
	     /glob "*"
	     /type "deny"
	}
	/0001 {
	     /glob "*.html"
	     /type "allow"
	}
       /0002 {
	     /glob "*.json"
	     /type "allow"
	}
}

 

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @Mario248 ,

Try this in /filter section of the dispatcher configuration

{ /type "allow" /url "/content/we-retail/us/en/men/jcr:content/root/text.model.json*" }

Hope that helps!
Regards,

Santosh

Avatar

Correct answer by
Level 7

Hi @Mario248 ,
If your flush agent is working properly, cache for http://localhost:4503/content/we-retail/us/en/men/jcr:content/root/text.model.json should be invalidated as soon as you activate page http://localhost:4503/content/we-retail/us/en/men.html If it is not happening please check  /invalidate section in your farm file and allow *.json. After adding this rule cache invalidation should work as expected. Please add rules as per your project. 

/invalidate {
	/0000 {
	     /glob "*"
	     /type "deny"
	}
	/0001 {
	     /glob "*.html"
	     /type "allow"
	}
       /0002 {
	     /glob "*.json"
	     /type "allow"
	}
}