473,595 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ 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 1812
On 30 May, 13:47, Don <don...@gmail.c omwrote:
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=123 4>
with
<http://example.com/files?docid=123 4&cache_buster= foo657658765576 56>
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.c omwrote:
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
1359
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 archive while the old copy is still in the archive. As a result, there are several files with the same name in the archive. Is it valid state of the archive? I would to achieve the result using a delete/remove operation, but it is also is not...
1
3144
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 rather than the one that has just been recompiled. Is there an recommended method for ensuring that a newly compiled DLL also gets copied over the DLL in the startup Exe's folder?
6
3849
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 use laptops. They have Access databases on their laptops and the data is replicated. The idea is that each case worker would scan their own documents, either remotely or back at the office. And NO I am not planning to store the scanned...
8
1596
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 would open in a new Internet Explorer window. Normally the user has the possibility to go on that link (without clicking with left mousebutton), pressing the right mouse button, going on copy location, open a new browserwindow by
10
9034
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 are NOT tech savvy, and wouldn't know what a "hard refresh" is, nor that it needed to be done.
4
3654
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; a programming "what if..?". i'm not concerned w/ manipulating a browser (i.e. prefs., settings this URL, always view SSR, save), but rather something i would code into the document which would request the browser to display in this mode (i.e....
12
3924
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 p5pe-vm motherboard and an Intel Pentium D 3.0Ghz processor, compared to the old one where we uses asrock motherboard and AMD Duron. Both has the same version of mysql installed... To summarized, both machine has the same configuration except...
0
4394
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 me to "clean up that mess you never use anyway and please dump the rest of it in the attic or simply throw that junk away". I want to make a statement here:
0
3490
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 discusses the internals of the Library class a bit more. Sections again A previous article part showed how Sections work, i.e. a group Section refers to book Sections, a book Section refers to chapter Sections and the latter refer
0
8261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3873
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
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 we have to send another system
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.