0

Two questions rolled into one.

Can browsers in general cache a URL (js script) if it's requested with URL variables? E.g. www.thing.com/?l=lib&s=thing.js

Can browsers cache a file if it is a php redirect? E.g. www.thing.com/script.js (called, is a php file with a redirect to www.thing2.com/actual.js)

Thanks.

Matt Cowley
  • 2,164
  • 2
  • 18
  • 29
  • 1
    A browser will generally cache any URL it's allowed (via cache policy headers, though a browser can still choose to ignore those), basically any request result may potentially be cacheable. However note that : `www.thing.com/?l=lib&s=thing.js` and `www.thing.com/?s=thing.js&l=lib` could be different in the eyes of the browser. – apokryfos Aug 05 '16 at 15:19

1 Answers1

2

Since you have two questions

  1. Can browsers in general cache a URL (js script) if it's requested with URL variables? E.g. www.thing.com/?l=lib&s=thing.js

    Yes.

  2. Can browsers cache a file if it is a php redirect? E.g. www.thing.com/script.js (called, is a php file with a redirect to www.thing2.com/actual.js)

    Depends. If the redirect is a 301, then yes 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.

    If the redirect is a 302, then 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.

Peter Bailey
  • 105,256
  • 31
  • 182
  • 206