Expand my Community achievements bar.

SOLVED

AEM 6.2 Caching

Avatar

Level 2

Hi all,

I have a component that has to render different depending on the end-user's geolocation (specifically, which country they are in). The component works correctly, when bypassing cache, however, if the first request to the page is a user from Canada (which should be rendered differently than other countries), and the second request comes in by an end-user from United States, the dispatcher will serve the version from Canada. I can see the cached HTML file in the dispatcher server, and understand it's directly serving this HTML file. Is there a way to disable cache for a specific page if a component is used? Or even better, is there a way to dynamically load the component per request?

Another interesting piece of info, is that the above form redirects to a page called payment-redirection.html, which has a custom component called paymentredirection on it. Now when this page is accessed, the caching structure is different than above. Instead of a direct "payment-redirection.html" file, there's a folder structure created: payment-redirection/jcr:content. In this directory are two files "contexthub.commerce.relatedproducts.json  contexthub.pagedata.json".

Both components are structured the same way, for the most part. Both are using Slightly, and the resource classes being used for both are using the @Model(adaptables = { SlingHttpServletRequest.class, Resource.class }) methodology.

Is it possible to render the first page and have it cache the page the same way as the "payment-redirection.html" page is being cached?

Thanks,

Danny

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Danny,

The part which are dynamic make use of ajax OR SSI. More details at Dispatcher Caching - New Features and Optimizations 

For payment redirection make use of selector.

Thanks,

View solution in original post

1 Reply

Avatar

Correct answer by
Level 9

Hi Danny,

The part which are dynamic make use of ajax OR SSI. More details at Dispatcher Caching - New Features and Optimizations 

For payment redirection make use of selector.

Thanks,