Here I will discuss a very interesting question generally asked during the interview & the question is –
“How will we cache query parameters in the Dispatcher cache?”
As we are working on AEM and it has a “Sling Script Resolution” concept. So if you have some value that you want it to be cached then you should use either selectors or suffixes because their responses will be cached on the dispatcher.
It’s a bad practice to cache query parameters but if you still want to do that then follow these steps.
Step I – Open dispatcher.any file. There is a configuration shown as –
#/ignoreUrlParams
# {
# /0001 { /glob “*” /type “deny” }
# /0002 { /glob “q” /type “allow” }
# }
Use this configuration for query parameters caching. As you can see this configuration is commented. So first remove comments from this configuration i.e.
/ignoreUrlParams
{
/0001 { /glob “*” /type “deny” }
/0002 { /glob “q” /type “allow” }
}
and add the query parameter for those you want to cache the response. for example –
/ignoreUrlParams
{
/0001 { /glob “*” /type “deny” }
/0002 { /glob “q” /type “allow” }
/0003 { /glob “x” /type “allow” }
}
Step 2 – Restart your Apache server.
Because of this configuration if you add “q” or “x” or both as query parameters, then their responses will be cached successfully.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.