3

If PHP does cache a permanent redirect:

  1. For how long?
  2. Can this period be changed?

I would also be interested in the default behaviour on this matter of Perl, Python, and any other languages used primarily for web development

mr-euro
  • 2,732
  • 5
  • 23
  • 27

2 Answers2

5

The http_fopen_wrapper.c which is used by file_get_contents() contains no caching logic whatsoever. In particular it responds to the Location: header only, and does not care for the actual HTTP status code. (It does not notice if it's a temporary redirect or a permanent.)

mario
  • 144,265
  • 20
  • 237
  • 291
  • Thx mario, my tests confirm the same. Even when responding with a 301, the "old" URI is still hit every single time. – mr-euro Apr 02 '11 at 22:25
-1

If you want more direct control over your http queries I suggest using curl.

Naatan
  • 3,424
  • 4
  • 32
  • 51
  • 2
    This doesn't answer his question at all, and should probably be posted as a comment. – Brad Apr 02 '11 at 22:15
  • I am serving the response header so do not have any control of the client's behaviour. Anyhow, would cURL cache the new location and use it on subsequent requests? – mr-euro Apr 02 '11 at 22:29