2

I use this code to retrieve some RSS feed:

$feed = 'http://www.example.com/rss';
$feed_to_array = (array) simplexml_load_file($feed);

This apparently caches the RSS feed, because i'm not getting new blog posts in. It works when I add a non existing variable to the url (like '?random=1234'). So there is a caching problem.

I searched stack overflow and the PHP docs, but I can't find the solution. Stuff like clearstatcache() doesn't work.

How do I prevent caching?

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
JacobF
  • 2,305
  • 3
  • 24
  • 36

1 Answers1

2

As far as I know, PHP does not provide any kind of cache for HTTP downloads.

My educated guess is that either your ISP or the remote site implement some kind of aggressive server-side caching technology (a proxy or an HTTP accelerator like Varnish). That's should not be difficult to test: load the same URL twice with a regular browser (Firefox, Chrome, whatever). Clear the browser cache if necessary.

The scenario can be more complex (your browser might be using a proxy or the remote cache might verify certain HTTP headers) but that should be the first check.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360