Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Caching pages with query

Avatar

Level 3

I would like to be able to cache pages that have a query. E.g, those with a querystring such as www.domain.com?q=search

We're fronting our installation with Akamai, and Akamai is already caching these URLs, but each 15mins Akamai will go back to the origin and fetch straight from the publisher again. Because there is no cached file for this URL. I'd like to change this.

One way I saw suggested to do this is:

1) Rewrite in apache to www.domain.com.q.search.html (or similar)

2) Then rewrite again in AEM to www.domain.com?q=search - I suspect using etc/map??

Can anyone suggest the rewrite rules I need in 1) and the mechanism I need in 2)

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 8

You did it right, the ignoreURLParameters setting ignores the query string and caches the page as if the query string wasn't in the URL. Normally the ignoreURLParameters is used to impact query parameters that don't impact the HTML to be returned, but rather impact the display client side or are used for analytic purposes. Examples might be an email campaign ID, or sorting parameter that is implemented client side. See http://docs.adobe.com/docs/en/dispatcher/disp-config.html#Ignoring URL Parameters. If you want to cache all the variations of a based on they query string you will have to rewrite them to selectors or something similar. 

View solution in original post

4 Replies

Avatar

Level 8

Rewriting the query string to a selector in Apache is the right way to make the requests cachable. 

Changing it back to query string with /etc/maps is bad idea in my opinion - your code that the renders the pages should look to pull the information out of the selector instead of the query string. 

Here are some examples of rewriting the query string https://wiki.apache.org/httpd/RewriteQueryString 

Avatar

Level 3

Sham, I initially wanted to use the /ignoreURLParameters setting, but the effect of using this is that query parameters are in fact ignored. So www.blog.com/page?tag=square is equal to www.blog.com/page?tag=triangle. They are saved in the apache layer as www.blog.com/page.html

Please correct me if that should work though, maybe I did something wrong on my end.

Avatar

Correct answer by
Level 8

You did it right, the ignoreURLParameters setting ignores the query string and caches the page as if the query string wasn't in the URL. Normally the ignoreURLParameters is used to impact query parameters that don't impact the HTML to be returned, but rather impact the display client side or are used for analytic purposes. Examples might be an email campaign ID, or sorting parameter that is implemented client side. See http://docs.adobe.com/docs/en/dispatcher/disp-config.html#Ignoring URL Parameters. If you want to cache all the variations of a based on they query string you will have to rewrite them to selectors or something similar.