URL 变量和 PHP 重定向,它们可以被缓存吗?

URL variables and PHP redirects, can they be cached?

两个问题合二为一。

如果使用 URL 变量请求,浏览器通常可以缓存 URL(js 脚本)吗? 例如。 www.thing.com/?l=lib&s=thing.js

浏览器可以缓存 php 重定向的文件吗? 例如。 www.thing.com/script.js(称为 php 文件,重定向到 www.thing2.com/actual.js)

谢谢。

既然你有两个问题

  1. 如果使用 URL 变量请求,浏览器通常可以缓存 URL(js 脚本)吗?例如。 www.thing.com/?l=lib&s=thing.js

    是。

  2. 浏览器可以缓存 php 重定向的文件吗?例如。 www.thing.com/script.js(称为 php 文件,重定向到 www.thing2.com/actual.js)

    视情况而定。如果重定向是 301,那么是 per the spec

    The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

    如果重定向是 302,则 maybe

    The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.