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
BedrockMission!

Learn More

View all

Sign in to view all badges

How to let the dispatcher not cache certain component?

Avatar

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Rui_J
Level 2

15-10-2015

Hi

  I have a componenet that has some dynamic content. And I don't want to dispatcher to cache this part.  So inspired by http://www.slideshare.net/netceteragroup/dynamic-components-using-singlepageapplication-concepts-in-... (Page 4), This is what I did, under apps/myapp/dynamicComponent, I have a two files, one is dynamicComponent.jsp and the other is dynamicComponent.dynamic.jsp, So in dynamicComponent.dynamic.jsp page, I have some JSP code to render the dynamic content. and in dynamicComponenet.jsp, I am using SSI to include this like this

<div color="red">render this</div> <!--# include virtual="<%=currentNode.getPath().replace("jcr:content","_jcr_content")%>.dynamic.html" />

So I decide to directly hit the page component link like this http://localhost:4505/content/myapp/mypage/_jcr_content/rightPar/dynamicComponent.dynamic.html page, and it didn't show me this red "render this" text, so apparently, it didn't render me anything.

Can someone tell me what is wrong?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back
Employee
Bruce_Lefebvre
Employee

Likes

28 likes

Total Posts

62 posts

Correct Reply

28 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Give Back
Employee
Bruce_Lefebvre
Employee

Likes

28 likes

Total Posts

62 posts

Correct Reply

28 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 25
Boost 10
View profile
Bruce_Lefebvre
Employee

15-10-2015

Try hitting your component without the 'dynamic' selector (for example, http://localhost:4505/content/myapp/mypage/_jcr_content/rightPar/dynamicComponent.html). The contents of dynamicComponent.jsp (including 'render this') will not be included in the response when the selector matches another script.

I would also suggest renaming dynamicComponent.dynamic.jsp to simply dynamic.jsp.

Answers (6)

Answers (6)

Avatar

Avatar
Give Back
Employee
Bruce_Lefebvre
Employee

Likes

28 likes

Total Posts

62 posts

Correct Reply

28 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Give Back
Employee
Bruce_Lefebvre
Employee

Likes

28 likes

Total Posts

62 posts

Correct Reply

28 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 25
Boost 10
View profile
Bruce_Lefebvre
Employee

15-10-2015

SSI includes are a feature of the web server, so you will need a dispatcher in front of your instance in order to use them (see answer at [0]). 

[0] also contains a suggestion to query WCMMode from within your JSP and use a <cq:include to make your content available in author mode, with no dispatcher present.

[0] https://forums.adobe.com/thread/1227938

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,122 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,122 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

15-10-2015

Hi,

You can use the "recent requests" view in the OSGI webconsole to get insight what a request was actually doing. I don't see any obvious problem in your usecase, so you might find there some more information.

kind regards,
Jörg

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct Reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

15-10-2015

Here is also a header that you can set for the request.

https://helpx.adobe.com/experience-manager/kb/DispatcherNoCache.html

Avatar

Avatar
Boost 5
Level 2
Tomasz_Sobczyk
Level 2

Likes

5 likes

Total Posts

14 posts

Correct Reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 5
Level 2
Tomasz_Sobczyk
Level 2

Likes

5 likes

Total Posts

14 posts

Correct Reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
Tomasz_Sobczyk
Level 2

15-10-2015

Hi Rui,

Did you ever bump upon this one:

https://github.com/Cognifide/Sling-Dynamic-Include

This library is doing exactly the thing that you are trying to implement, so maybe instead of reinventing the wheel... 😉

Avatar

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Rui_J
Level 2

15-10-2015

Hi,

  Thanks for the link. It is really helpful! I have managed to setup the SSI. But One thing confusing me is how do I differ the WCMMode in publish instance from dispatcher? This is what I wrote in the code, author and dispatcher are working fine, But the publish instance does not show. Any idea?

<% String path = currentNode.getPath().replace("jcr:content", "_jcr_content") +".dynamic.html"; %> <% boolean authormode = ((WCMMode.fromRequest(request) == WCMMode.EDIT) || (WCMMode.fromRequest(request) == WCMMode.DESIGN) ||(WCMMode.fromRequest(request) == WCMMode.PREVIEW) ); if (authormode) { %> <sling:include path="<%=path%>" /> <% } else { %> <!--#include virtual="<%=currentNode.getPath().replace("jcr:content", "_jcr_content")%>.dynamic.html" /> <% }

Avatar

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
Rui_J
Level 2

Likes

4 likes

Total Posts

39 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Rui_J
Level 2

15-10-2015

Bruce Lefebvre wrote...

Try hitting your component without the 'dynamic' selector (for example, http://localhost:4505/content/myapp/mypage/_jcr_content/rightPar/dynamicComponent.html). The contents of dynamicComponent.jsp (including 'render this') will not be included in the response when the selector matches another script.

I would also suggest renaming dynamicComponent.dynamic.jsp to simply dynamic.jsp.

 

I have changed to dynamic.jsp, yes, it starts to show some right thing. At least this "render this" is showing up. So I guess I am on the right track. But now, how do I do a SSI include?

Till now if I directly hit the  http://localhost:4505/content/myapp/mypage/_jcr_content/rightPar/dynamicComponent.html, I can see the component is showing correctly. But When I put this code to dynamicComponent.jsp  it just not show the include. Any idea why?

<div color="red">render this</div> <!--# include virtual="<%=currentNode.getPath().replace("jcr:content","_jcr_content")%>.dynamic.html" -->