Hi,
I have a use case , where I want to cache the page at dispatcher but I want to dynamically include a particular component, while being able to access the request parameter present in the URL.
e.g.
www.website-url.com?keyword=test
I want the page to be served from dispatcher cache, but I need to access keyword - test in the component model, so that I can do some processing and return the result.
I am using the dynamic include bundle for getting component dynamically
Without caching the page, I can access using request.getParameter('keyword') in component model, but when I cache the page and load component dynamically (using dynamic-include) , then request parameter is not accessible as dispatcher is not passing it. Any help would be appreciated.
Solved! Go to Solution.
Actually the SSI handling happens before the AEM dispatcher, so if the SSI starts a new sub-request to the same hostname as the initial request, it will eventually end up at the dispatcher. The documentation at [1] provides details how you need to configure your Apache httpd to make it work.
The difference to the "standard" combination of SDI and SSI is just that you need to change the SSI statements to fine-tune the URL for the dynamic component.
hi,
request.getParameter('keyword') execute only in AEM server, so in order to use this logic, your page/part of page should not be cached.
Ideally this kind of functioanlity with caching is handled from front end where you read query param and fetch dynamic content using ajax.
Hi Arun,
Thanks for the response. Actually our current implementation is based on dynamic include and we are hoping that if we are able to pass query parameters (to the server) while loading the non-cached component, then, our problem would be solved.
I agree, we can solve it (or any such use-case via ajax) , but isn't the dynamic include trying to solve the same use-case?
So just wanted to know, is there any specific reason for why apache dispatcher module doesn't send the request parameters along with dynamic include request? It looks like a natural extension to the dynamic include feature , in my opinion.
ok, to make it concrete:
Your page is https://mysite.com/page.html , and you use SDI (using SSI) to load some dynamic parts of it. The request from Dispatcher to AEM is https://mysite.com/page.dynamic.html.
In your case you need to get the parameter from
https://mysite.com/page.html?keyword=test to https://mysite.com/page.dynamic.html?keyword=test.
This is a matter of SSI, that this sub-request is created with all parameters which are provided to the initial request. Not sure if that's possible just with the SSI subsystem of Apache httpd (I am not really familiar with it). Maybe you can ask on the Sling User list for some ideas?
* Disclaimer - I and @sarthakuiit are in the same team *
Thanks @Jörg_Hoh for your response, you got it right. We want sub-requests to have all the request parameters as in the original request.
I think this is the responsibility of Apache (AEM Dispatcher) module to pass on all request parameters to dynamic request but unfortunately it doesn't do that. I am not sure who owns dispatcher module (I guess Adobe) but it looks like it is not open source so we can't think about extending it.
Is there any forum (may be mailing list) where we can request this feature or have a discussion around it? It might be useful for anyone using SSI as they don't have to use ajax just to support this basic use case. I would also be interested in knowing if there is a good reason behind not supporting the request parameters as I might be missing something important here.
Thanks!
Actually the SSI handling happens before the AEM dispatcher, so if the SSI starts a new sub-request to the same hostname as the initial request, it will eventually end up at the dispatcher. The documentation at [1] provides details how you need to configure your Apache httpd to make it work.
The difference to the "standard" combination of SDI and SSI is just that you need to change the SSI statements to fine-tune the URL for the dynamic component.
.
Hi Jörg ,
Thanks for the response. Your inputs were really helpful.
Sharing the specifics for others' benefit.
We could figure out the solution for our problem in the documentation of mod_include.
There is a variable named - QUERY_STRING , which provides the request parameter query string.
As we have customized the code for dynamic include already, we modified the URL of component in virtual include section like -
<!--#include virtual="page_path/_jcr_content/component_path.nocache.html?$QUERY_STRING" -->
for the first request which comes to the server.
For subsequent requests , when the dispatcher sends the SSI request to AEM publish instance, it sends the request parameter information as well, which we could read and solve our problem.
Thank you once again!
Thanks for sharing the solution!
Hi @sarthakuiit
As @arunpatidar mentioned you can use front end logic to read query parameters or you can write apache rewrite to achieve this but I wont recommend this.
I think you can also use selectors instead of query parameters to fulfill your requirements, and this will be cached also.
Thanks
Dipti
Hi Dipti,
Thanks for the response. We came across the option for using selectors while searching, but the problem is that, it is a search page and there will be a lot of cached pages for all the search terms (in thousands). That's why we didn't go that route.
I was just curious to know, if it is possible to pass the request params , when dispatcher fires request to server to load the non-cached component. Also, I was wondering, why this option is not implicitly present.
What exactly is apache rewrite option? - Do you mean converting request params to sling selector in apache server ?
Hi @sarthakuiit
If you are using the Sling Dynamic Include to achieve the dynamic inclusion of component then you should be able to read the paramater as well. SDI config provides the parameter (Ignore URL params) where SDI normally skips requests containing any GET parameters. This option allows to set a list of parameters that should be ignored. So if you want to pass any specific parameter that should be passed from dispatcher to your publish instance, you can define here and using the requestParameter it should be accessible.
include-filter.config.ignoreUrlParams="[]"
Thanks!
Thanks for your reply @Asutosh_Jena_ !
Based on our tests, we are able to read the request params in AEM only if the whole page is being served by AEM. If we have a dynamic include component and we allow page to be cached in dispatcher, then whenever Dispatcher makes SSI (dynamic request) to AEM it is not sending the request params which were part of the original request. This looks like Dispatcher related issue/feature.
I am not sure how can we achieve it using the sling dynamic include config as you mentioned:-
include-filter.config.ignoreUrlParams="[]"
According to my understanding, it is responsible for writing either SSI or actual component's markup based on where URL is having any params which is part of ignoreUrlParams or not. It can change what we are sending from AEM to Dispatcher (which gets cached) but not what dispatcher should sent to AEM dynamically.
Please correct me if my understanding is wrong.
Views
Likes
Replies