Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Not able to invalidate JSON in dispatchers

dragon2A
Level 6
Level 6

As per our requirements we are caching the pages in dispatcher  like this format ex :- /content/eacom0/en_us/help/Sam_Test_Availability_Alpha_Beta_Demo/jcr:content.-1.json .

The problem here is I am not able to invalidating the jcr:content.-1.json by using the dispatcher configurations.

Any suggestions or solutions for this. 

Thanks In Advance. 🙂

9 Replies
dragon2A
Level 6
Level 6

I have tried everything except the sling Servlet.

Does there any way to handle via the configurations instead of the servlet. ?

Jörg_Hoh
Employee
Employee

What do you mean with "I am not able to invalidate ..."? What have you tried? Can you set the dispatcher on loglevel DEBUG and post the relevant logs then?

Kind regards,
Jörg

dragon2A
Level 6
Level 6

We are caching the pages using JSON format like this /jcr:content.-1.json .

After publishing of the page , we are able to cache dispatcher but when we do modifications and reactivated the page it suppose to clean that cache at the time of reactivation (by using the triggers in publisher agents).

But what is happening its not invalidating/clearing the cached JSON in dispatcher , The result is we are unable to get the latest changes . We always getting the first one.

With same configurations We are able to invalidate the .html in dispatcher after the reactivation of the pages.

I hope you understand the situation 🙂

Ashokkumar_TA
Level 2
Level 2

Can you share the /invalidate section of your dispatcher.any configuration and the dispatcher log entries...

dragon2A
Level 6
Level 6

Here is my invalidation configuration in dispatcher.

/invalidate
        {
        /0000
          {
          /glob "*"
          /type "deny"
          }
        /0001
          {
          # Consider all HTML files stale after an activation.
          /glob "*.html"
          /type "allow"
          }
        /0002
          {
          /glob "/etc/segmentation.segment.js"
          /type "allow"
          }
        /0003
          {
          /glob "*/jcr:content/.-1.json"
          /type "allow"
          }
        }

Jörg_Hoh
Employee
Employee

Please replace the "/jcr:content/.1.json" with ".json".

Jitendra_S_Toma
Level 9
Level 9

Actually, JSON caching isn't done the way you have http request. Just clarify this is your request..*/jcr:content/.-1.json but caching folder is _jcr_content

So, just try URL like this in invalidating section. One more thing, Just guessing that Dot could be an issue but not sure. it is symbol for hidden files.

     /0003
          {
          /glob "*/_jcr_content/.-1.json"
          /type "allow"
          }

--Jitendra

dragon2A
Level 6
Level 6

I am able to clear the cache by using the post call. Thanks everyone.

dragon2A
Level 6
Level 6

I am able to solve this problem with use of POST servlet . 

 


            HttpClient client = new HttpClient();
 
            PostMethod post = new PostMethod("http://"+host+uri);
           // post.addRequestHeader("Content-Type", "application/json");
            post.setRequestHeader("CQ-Action", "Activate");
            post.setRequestHeader("CQ-Handle",handle);
             
            StringRequestEntity body = new StringRequestEntity(page,null,null);
            post.setRequestEntity(body);
            post.setRequestHeader("Content-length", String.valueOf(body.getContentLength()));
            client.executeMethod(post);
            post.releaseConnection();