How to force dispatcher cache urls with get parameters

↘锁芯ラ 提交于 2019-12-11 04:08:03

问题


As I understood after reading these links:

How to find out what does dispatcher cache?

http://docs.adobe.com/docs/en/dispatcher.html

The Dispatcher always requests the document directly from the AEM instance in the following cases:

If the HTTP method is not GET. Other common methods are POST for form data and HEAD for the HTTP header.
If the request URI contains a question mark "?". This usually indicates a dynamic page, such as a search result, which does not need to be cached.
The file extension is missing. The web server needs the extension to determine the document type (the MIME-type).
The authentication header is set (this can be configured)

But I want to cache url with parameters.

If I once request myUrl/?p1=1&p2=2&p3=3

then next request to myUrl/?p1=1&p2=2&p3=3 must be served from dispatcher cache, but myUrl/?p1=1&p2=2&p3=3&newParam=newValue should served by CQ for the first time and from dispatcher cache for subsequent requests.


回答1:


I think the config /ignoreUrlParams is what you are looking for. It can be used to white list the query parameters which are used to determine whether a page is cached / delivered from cache or not.

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




回答2:


It's not possible to cache the requests that contain query string. Such calls are considered dynamic therefore it should not be expected to cache them.

On the other hand, if you are certain that such request should be cached cause your application/feature is query driven you can work on it this way.

  1. Add Apache rewrite rule that will move the query string of given parameter to selector
  2. (optional) Add a CQ filter that will recognize the selector and move it back to query string

The selector can be constructed in a way: key_value but that puts some constraints on what could be passed here.




回答3:


You can do this with Apache rewrites BUT it would not be ideal practice. You'll be breaking the pattern that AEM uses.

Instead, use selectors and extensions. E.g. instead of server.com/mypage.html?somevalue=true, use: server.com/mypage.myvalue-true.html

Most things you will need to do that would ever get cached will work this way just fine. If you give me more details about your requirements and what you are trying to achieve, I can help you perfect the solution.



来源:https://stackoverflow.com/questions/27290738/how-to-force-dispatcher-cache-urls-with-get-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!