Can I stop iCal from caching my PHP-generated iCalendar feed?

1.1k views Asked by At

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

2

There are 2 answers

0
Crashspeeder On

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
?>
0
Ben D On

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' ); 
?>