如何使用get参数强制调度程序缓存URL

问题描述 投票:2回答:3

据我读完这些链接后的理解:

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)

但我想用参数缓存url。

如果我曾经请求myUrl/?p1=1&p2=2&p3=3

然后,必须从调度程序缓存提供对myUrl/?p1=1&p2=2&p3=3的下一个请求,但myUrl/?p1=1&p2=2&p3=3&newParam=newValue应首次由CQ服务,并从后续请求的调度程序缓存服务。

apache caching cq5 dispatcher aem
3个回答
3
投票

我认为配置/ignoreUrlParams是你正在寻找的。它可用于白名单查询参数,这些参数用于确定页面是否从缓存中缓存/传递。

查看http://docs.adobe.com/docs/en/dispatcher/disp-config.html#Ignoring%20URL%20Parameters了解详情。


1
投票

无法缓存包含查询字符串的请求。这样的调用被认为是动态的,因此不应该期望它们被缓存。

另一方面,如果您确定应该缓存此类请求,因为您的应用程序/功能是查询驱动的,您可以通过这种方式处理它。

  1. 添加Apache重写规则,将给定参数的查询字符串移动到选择器
  2. (可选)添加一个CQ过滤器,它将识别选择器并将其移回查询字符串

选择器可以用以下方式构造:key_value但是对可以在这里传递的内容施加一些约束。


1
投票

你可以用Apache重写这样做,但这不是理想的做法。你将打破AEM使用的模式。

相反,使用选择器和扩展。例如。而不是server.com/mypage.html?somevalue=true,请使用:server.com/mypage.myvalue-true.html

您将需要执行的大多数事情都可以通过这种方式正常工作。如果您向我提供有关您的要求以及您想要实现的目标的更多详细信息,我可以帮助您完善解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.