Caching pages with query

Avatar

Avatar

Katrien1

Avatar

Katrien1

Katrien1

15-10-2015

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!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Paul_McMahon

MVP

Avatar

Paul_McMahon

MVP

Paul_McMahon
MVP

15-10-2015

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. 

Answers (3)

Answers (3)

Avatar

Avatar

Katrien1

Avatar

Katrien1

Katrien1

15-10-2015

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

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K
Sham_HC

15-10-2015

Why don;t just ignore the url param in dispatcher by following

http://docs.adobe.com/docs/en/dispatcher/disp-config.html#Ignoring%20URL%20Parameters

Avatar

Avatar

Paul_McMahon

MVP

Avatar

Paul_McMahon

MVP

Paul_McMahon
MVP

15-10-2015

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