Hello
Does anybody know how to make FireFox to cache data that comes via
XMLHttpRequest? Here is the issue I deal with:
- On the web server (apache2) I have a static xml file test.xml
- When I download test.xml using XMLHttpRequest, FireFox always gets
complete test.xml from the server, thus not using the browser cache
(apache sends 200 OK back to FireFox).
- If I look into the HTTP request and the HTTP response, I can see
that FireFox seems to always set the following request headers:
Pragma: no-cache
Cache-Control: no-cache
- Apache always sets Last-Modified and ETag headers in a response.
I tried the same JavaScript code with IE, and IE definitely relies on
its cache: I can see in Apache logs responses with 304 Not Modified
code for IE, also HTTP requests from IE have If-Modified-Since and
If-None-Match headers. I didn't find any difference in responses Apache
provides for FireFox and IE.
Any ideas? It would be nice to make caching work in FireFox.
Regards,
Sergey Surkov 3 12629
Try
....
yourRequest.set RequestHeader(" Pragma", "");
yourRequest.sen d(null);
....
(Takes out of the game Opera & Co though, because their XmlHttpRequest
is broken on headers mechanics).
Sergey Surkov wrote: Does anybody know how to make FireFox to cache data that comes via XMLHttpRequest? Here is the issue I deal with: - On the web server (apache2) I have a static xml file test.xml - When I download test.xml using XMLHttpRequest, FireFox always gets complete test.xml from the server, thus not using the browser cache (apache sends 200 OK back to FireFox). - If I look into the HTTP request and the HTTP response, I can see that FireFox seems to always set the following request headers: Pragma: no-cache Cache-Control: no-cache - Apache always sets Last-Modified and ETag headers in a response.
I tried the same JavaScript code with IE, and IE definitely relies on its cache: I can see in Apache logs responses with 304 Not Modified code for IE, also HTTP requests from IE have If-Modified-Since and If-None-Match headers. I didn't find any difference in responses Apache provides for FireFox and IE.
You can set HTTP request headers if you need to
var httpRequest = new XMLHttpRequest( );
httpRequest.ope n('GET', 'file.xml', true);
httpRequest.set RequestHeader(' Cache-Control',
'desired cache value here')
--
Martin Honnen http://JavaScript.FAQTs.com/
Thanks for the reply. I couldn't make it work, though.
It seems that the meaning of setRequestHeade r for these two headers
(Pragma and Cache-Control) is extension of the defaults, not
replacement. For example, if I say setRequestHeade r("Cache-Control",
"public"), the actual header becomes Cache-Control: no-cache, public.
Or if I say setRequestHeade r("Pragma", "sergey=sergey" ), the result is
Pragma: sergey=sergey, no-cache. Other headers may work differently: I
tried modifying Keep-Alive and the resulting header was correct.
I'm also inclined to think that if there is a solution to the
problem, it shouldn't deal with manually setting HTTP request headers.
The reason is for a browser to send a conditional GET, it has to
provide an ETag or a last modified date so that a server could
determine if the cache entry is osbsolete. These values are stored (if
they are stored) inside browser cache and are probably not available to
JavaScript on a web page.
Am I still missing something? Does anybody have a successfull
experinece of Firefox using browser cache for XMLHttpRequest
transactions? Maybe it's a well known bug and there is a workaround?
Sergey This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: warteschlange |
last post by:
Martin Honnen wrote:
>You can set HTTP request headers if you need to
> var httpRequest = new XMLHttpRequest();
> httpRequest.open('GET', 'file.xml', true);
> httpRequest.setRequestHeader('Cache-Control',
> 'desired cache value here')
if you send
httpRequest.setRequestHeader('Cache-Control', 'public'); or
httpRequest.setRequestHeader('Cache-Control', 'max-age=3600, public');
|
by: kwilder |
last post by:
This works, but it doesn't load the latest version of the xml if it was
just modified without closing and reopening the browser.
Here's the scenario:
I have an xml doc called results.xml. It can contain lots of data.
<Results>
<Data>Stuff</Data>
<Data>More stuff</Data>
|
by: Greg |
last post by:
Hi,
I've designed a bookmark in Ajax / PHP that I will put soon on
sourceforge.net.
But I've got an very tricky bug.
I try it on some computers with Internet Explorer/Windows, Firefox
1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac,
Safari/Mac.
It works perfectly on a lot of configurations but, on some PC with
Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
|
by: TLaufenberg |
last post by:
I'm new to Javascript programming and I've run into a bit of a snag
with making an XMLHttpRequest in the Safari browser. Actually, the
request doesn't work in Firefox either but only when I use a Mac
computer. IE and FireFox on a Windows based system works just fine. The
problem I am having is that the XMLHttpRequest doesn't open the site
that I've programmed into it. When I check the readyState it only
returns 0 and never goes through the...
|
by: Peter Michaux |
last post by:
Hi,
The FAQ correctly says the following:
"Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the
Windows version of IE versions 5+, and some other browsers provide the
XML HTTP Request object."
In my haze of testing yesterday it seems that NN6.1 provides an
non-functional XMLHttpRequest object and NN6.2 XMLHttpRequest object
| |
by: geevaa |
last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3
XMLHttpRequest and AJAX for PHP programmers
James Kassemi
Introduction:
Although the concept isn't entirely new, XMLHttpRequest technology is
implemented on more sites now than ever. Compatibility is no longer an
issue (IE, Mozilla and Opera all support it), and the benefits to
using it are amazing. There are too many PHP programmers avoiding any
|
by: HugeBob |
last post by:
Hi All,
I've got a question about Asynchronous vs Synchronous mode with the
XMLHttpRequest object. What are the ramifications of using one mode
vs the other? If the script uses Asynchronous mode, it sounds as if a
thread retrieves the data from the supplied URL and the JS function
that called the open() and send() methods continues on. Where as
using Synchronous mode the method that called open() and send() waits
until the data from...
|
by: Iain Adams |
last post by:
My code is as follows.
http_request = false;
if (window.XMLHttpRequest) {
alert("firefox");
http_request = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
alert("ie");
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |