On 30 May, 13:47, Don <don...@gmail.comwrote:
Quote:
Is it possible to create a link which will cause either A) the server
to serve a fresh copy of a file or B) the browser to "refresh" the
copy of the file.
|
Yes and no.
HTTP is "RESTful" (look it up), which means that you can't do this (as
stated). There's a link on a page which tells you the URI by which to
retrieve that web resource. What happens when you try to retrieve that
URI-identified resource is entirely up to the server that serves the
file in response to the URI. If it "thinks that you need" a new file,
it can send you one. Otherwise it will send the old file again, or
send headers that indicate to the browser it can continue to use the
old one. There's no "flag mechanism" alongside the URI to indicate
"Yes, I really want a new one", certainly not one that a HTML page
with an embedded <a href="..." can send to the browser.
OTOH, if there are multiple URIs that return the same file, but that
look dissimilar to naive browsers, then it's very easy to hack your
way past this. Try mangling the URI with an extra meaningless query
parameter. This will usually make a cache (internal to the browser or
external) treat this as a separate web resource, but the server will
end you the same content and the browser will download and store it
equally.
e.g. replace
<http://example.com/files?docid=1234>
with
<http://example.com/files?docid=1234&cache_buster=foo65765876557656>
The real way though is to configure the server (.htaccess isn't that
scary) so as to return HTTP Response headers indicating that the file
shouldn't ever be cached, or (better) that it has a very short expiry
lifetime.