How to cache json response in diaptcher for content as service in aem 6.5 | Community
Skip to main content
Mario248
Level 7
June 27, 2022
Solved

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

  • June 27, 2022
  • 2 replies
  • 3371 views

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)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sunil_kumar_

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"
	}
}

 

2 replies

SantoshSai
Community Advisor
Community Advisor
June 27, 2022

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

Santosh Sai
sunil_kumar_
sunil_kumar_Accepted solution
Level 5
June 28, 2022

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"
	}
}