简体   繁体   English

具有日期时间的事件的放大器列表

[英]amp-list for events with a datetime

I have recently build an site in amp. 我最近在amp中建立了一个站点。 Most things are working really nicely except I am having an issue with caching. 除了我在缓存方面遇到问题外,大多数事情都运行良好。

I have a list of events which comes from a DB in php. 我有一个来自php中数据库的事件列表。 Each event has a datetime and then list is ordered by this field. 每个事件都有一个日期时间,然后按此字段对列表进行排序。 What is happening now is the page is caching on mobile for days, so it shows old events if you have been to the page already. 现在正在发生的事情是该页面在移动设备上缓存了几天,因此如果您已经访问过该页面,它就会显示旧事件。

I started to look at amp list and creating json, but with the limitations of mustache being logicless I couldn't work out a way to only show events in the future. 我开始查看放大器清单并创建json,但是由于胡须的限制是无逻辑的,所以我无法找到一种仅在将来显示事件的方法。

Does anyone know if this is at all possible? 有人知道这是否完全可能吗?

Thanks in advance 提前致谢

Richard 理查德

您可以将数据获取到AMP状态,然后在状态变量上使用绑定表达式来实现某种级别的逻辑。

Two options: 两种选择:

  1. Serve your documents with a lower max-age caching header to ensure that the AMP Cache does not show stale data (the minimum value is 15s). 为您的文档提供较低的max-age缓存标头,以确保AMP缓存不显示陈旧数据(最小值为15s)。 Read more about this in the AMP Cache documentation . AMP Cache文档中了解有关此内容的更多信息。
  2. When using amp-list, you should filter the events server-side with every request to only show the ones that are still in the future. 使用amp-list时,应在服务器端对每个请求进行事件过滤,以仅显示将来的事件。

My recommendation would be option 1 as it avoids the additional complexity and provides a better user experience (content is directly rendered without having to make a second request to pull in content via amp-list). 我的建议是选项1,因为它避免了额外的复杂性并提供了更好的用户体验(直接呈现内容,而无需再次提出通过amp-list提取内容的请求)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM