简体   繁体   English

缓存供稿,仅在更改供稿时刷新

[英]Cache feed and only refresh when feed is changed

Over at rsscache they have a way of refreshing the cache only when the feed has changed. rsscache上,它们只有在feed更改时才有刷新缓存的方法。 Unfortunately its .Net. 不幸的是它的.Net。

I would like to know what approach I should take to achieve this in php. 我想知道我应该采取什么方法在php中实现这一目标。

How are changes in the feed detected? 如何检测到提要中的变化? Simply by a timestamp (time node in the beginning of the feed)? 只是通过时间戳记(提要开头的时间节点)?

My feed would be a yahoo pipe that has mixed many feeds together. 我的提要是将许多提要混合在一起的Yahoo管道。 So either the yahoo feed must generate a combined timestamp, or my cache mechanism must automagically detect if the pipe has changed. 因此,要么yahoo提要必须生成组合的时间戳记,要么我的缓存机制必须自动检测管道是否已更改。

You have to: 你必须:

  • Store when the content you have cache was last stored (read the server's Last-modified header). 存储您上次缓存的内容的最后存储时间(读取服务器的Last-modified标头)。
  • Make conditional GET requests (send the header If-modified-since ). 发出条件GET请求(发送标头If-modified-since )。

The server will either respond with 200 (OK) and the content or 304 (Not Modified) and an empty response body. 服务器将以200 (确定)和内容或304 (未修改)和空的响应正文进行响应。

See RFC 2616 . 参见RFC 2616

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

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