473,473 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Forcing retrieval of a fresh copy of a file with a link

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

Doing it via a link is the only possibility that I think would be
viable for our situation, as changing HTTP headers isn't really
feasible/desired right now (think 'expires' or 'no-cache'). Also, the
file is non-HTML, so adding a 'no cache' meta tag to the file itself
won't work. The file in question has no file extension and contains
text-only excerpts from Apache access logs; parsing it as HTML or PHP
causes it to jumble the line endings and cram everything up, making it
unreadable.

So...Is there a way to add something to the A HREF= tag or create some
other sort of link that can do this? We're also open to other
possibilities which don't involve HTTP headers (or at least the
modification of .htaccess, httpd.conf, etc.).
Jun 27 '08 #1
3 1797
On 30 May, 13:47, Don <don...@gmail.comwrote:
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.

Jun 27 '08 #2
Don
[...snip...]

AWESOME post, Andy! For right now I'm trying putting the UNIX time
stamp at the end of the file request (as in http://example.com/searchfile2?1212158868).
Hopefully that works for what we need. This is for work and it's just
an internal utility that my boss and I use to look at part of the
access logs, so I guess it's not really mission critical and doesn't
need to be all that robust (although I suppose that in practice, being
in the habit of creating robust code/systems would be a good idea).

Since it's for work and the server hosts one of our company's
websites, I'd definitely like to be more comfortable with editing the
config files before I start playing around with the HTTP headers
in .htaccess or httpd.conf or wherever. I'll probably poke around in
the Apache install I have on one of my home Linux machines.

Thanks again!
Jun 27 '08 #3
On 30 May, 15:52, Don <don...@gmail.comwrote:
Since it's for work and the server hosts one of our company's
websites, I'd definitely like to be more comfortable with editing the
config files before I start playing around with the HTTP headers
in .htaccess or httpd.conf or wherever.
So long as you learn and test with .htaccess, you can only screw-up
the sub-tree beneath where you're editing. To break the whole server
requires httpd.conf
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Åâãåíèé Êîñåíêî | last post by:
Hi! I need to fresh a zip-archive using zipfile. However, it seems it is no function to fresh the archive. When I use the append-mode of ZipFile, the written file is merely appended to the...
1
by: _D | last post by:
When debugging an assembly, obviously a startup Exe file must be set. I've run into a snag once in a while that appears to be caused by VS referring to the Exe's *local* copy of the target DLL...
6
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who...
8
by: Axel Gallus | last post by:
I want to realize the following.... The user logs in to a certain webpage (username & password). Then the user sees a html page with a link in it. This link is a target="_blank" link, so it...
10
by: hughestroop | last post by:
I have updated my CSS and if you view the main page with the old css cached, it breaks the page. Is there any way to force viewers that have the old css cached to get the new css? Our viewers...
4
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea;...
12
by: grace | last post by:
i am wondering why my database retrieval becomes too slow...we set up a new server (ubuntu, breezy badger) machine where we transferred all our files from the old server.. Our new server uses Asus...
0
by: JosAH | last post by:
Greetings, Introduction At the end of the last Compiler article part I stated that I wanted to write about text processing. I had no idea what exactly to talk about; until my wife commanded...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.