Caching pages with query | Community
Skip to main content
Level 3
October 16, 2015
Solved

Caching pages with query

  • October 16, 2015
  • 4 replies
  • 5603 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PaulMcMahon

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. 

4 replies

Level 8
October 16, 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 

Sham_HC
Level 10
October 16, 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

Katrien1Author
Level 3
October 16, 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.

PaulMcMahonAccepted solution
Level 8
October 16, 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.