我可以阻止 iCal 缓存 PHP 生成的 iCalendar 源吗?

发布于 2024-12-29 22:00:05 字数 316 浏览 5 评论 0原文

我用 PHP 制作了一个动态生成的 iCalendar feed,遵循 RFC 5545。它在大多数情况下工作得很好,除了 iCal(即 Mac OS X 的内置日历程序)似乎拒绝反映对其先前已下载的事件的更新。我假设这是由于缓存造成的。有没有办法告诉 iCal 不要缓存我的 Feed?

编辑:哦,是的,我忘了提及,我已经尝试让每个 VEVENT 在每次调用 feed 时都有不同的 UID(我的 UID 格式是“id”,其中是 RFC 5545 的日期时间格式中的当前时间,是我的数据库中事件的唯一 ID)。我还尝试过使用标题中的内容类型;无论我将其设置为文本/纯文本还是文本/日历,都会出现此问题

I made a dynamically generated iCalendar feed with PHP, sticking to RFC 5545. It's working just fine for the most part, except iCal (i.e. Mac OS X's built-in calendar program) seems to refuse to reflect updates to events it had previously already downloaded. I'm assuming this is due to caching. Is there a way I can tell iCal not to cache my feed?

EDIT: Oh yeah, I forgot to mention that I've already tried making each VEVENT have a different UID each time the feed is called (my UID format is "id", where is the current time in RFC 5545's DATE-TIME format, and is the unique ID of the event in my database). I've also tried playing with the Content-type in the header; this problem happens whether I set it to text/plain or text/calendar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陪你搞怪i 2025-01-05 22:00:05

我从未处理过 iCal,但尝试设置标头以强制重新验证。

<?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

I've never dealt with iCal but try setting the headers to force revalidation.

<?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
溺孤伤于心 2025-01-05 22:00:05

您是否尝试过添加“无缓存”标头?

<?php
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); //date in the past
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); //tell it we just updated
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //force revaidation
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' ); 
?>

Have you tried adding "no-cache" headers?

<?php
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); //date in the past
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); //tell it we just updated
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //force revaidation
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' ); 
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文