Can dispatcher cache be disabled for selected clients?
In a recent project we ran into this scenario. We wanted to have
automated testing to validate if the content cached in the dispatcher matches
with the content served from AEM.
The tricky part is that the automated test runs on a desktop
which cannot directly connect to the publish instance. The request to get the
content served from AEM should also be routed through the dispatcher.
We were looking for a solution by which the client can set a
flag to indicate if the response needs to be served from the cache or be
fetched directly from AEM
Query Parameter to our rescue
We handled this using a query parameter. The query parameter
(we called it ignoreCache) would be set for requests that needs to fetch the
response directly from AEM.
The dispatcher configuration
Setup the /ignoreUrlParams section of dispatcher
configuration to not ignore the 'ignoreCache'
parameters
/ignoreUrlParams
{
#Configuration as needed
...
#Add line to deny ignoreCache parameter
/0099 { /glob "ignoreCache" /type "deny" }
}
With this configuration done, the dispatcher would ignore
caching & serving from its cache, all the requests with the parameter ‘ignoreCache’
included. Such requests gets passed it to an AEM renderer instance for
processing.
Now all that remains to be done is to write test cases to make
two requests one with the 'ignoreCache' parameter & another without this
parameter and compare the response of these two requests to validate the
content served from AEM against the one served from dispatcher cache
Using Cookies
Another option is to set 'ignoreCache' as a cookie. But the dispatcher
configuration does not support using cookies to differentiate the requests for
handling.
In this case use URL rewrite feature of Apache to fetch this
cookie if set and add it as a URL parameter before the request is passed on to
the dispatcher.
Once the URL parameter is set, the ignoreUrlParams configuration
kicks in to make sure that all requests with this parameter set are fetched
directly from AEM and not served from cache.
No comments:
Post a Comment