Does PHP's file_get_contents cache a 301 status code?

怎甘沉沦 提交于 2019-12-07 12:27:14

问题


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


回答1:


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.)




回答2:


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



来源:https://stackoverflow.com/questions/5526209/does-phps-file-get-contents-cache-a-301-status-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!