Setup the test environment:
1. /test.html
<script type="text/javascript">
$(document).ready(function(){
$("#load").click(function(){$("#test").load("/test.txt");});
});
</script>
...
<div id="test"></div>
<input id="load" type="button" value="Load test.txt" />
...
2. /test.txt
John Locke Lives
3. Apache 2.x httpd.conf
Make sure expires_module is loaded:
LoadModule expires_module modules/mod_expires.so
4. /.htaccess
ExpiresActive On
ExpiresByType text/plain "access plus 1 year"
5. Clear cache of Firefox 4
Options->Advanced->Network->Offline Storage, Clear Now
6. Firebug is ready to use
Begin test:
1. Visit localhost/test.txt
Status: 200 OK
Response Headers:
...
Last-ModifiedTue, 29 Mar 2011 07:53:12 GMT
Cache-Controlmax-age=31536000
ExpiresWed, 28 Mar 2012 10:06:40 GMT
...
2. Press Refresh button of Firefox browser
Status: 304 Not Modified
Response Headers:
...
Last-ModifiedTue, 29 Mar 2011 07:53:12 GMT
Cache-Controlmax-age=31536000
ExpiresWed, 28 Mar 2012 10:08:32 GMT
....
Just as I expected.
3. Clear beowser cache
4. Visit localhost/test.html, press button to load test.txt
5. Find GET /test.txt line in Firebug
Status: 200 OK
Response Headers:
...
Last-ModifiedTue, 29 Mar 2011 07:53:12 GMT
Cache-Controlmax-age=31536000
ExpiresWed, 28 Mar 2012 10:15:24 GMT
...
6. Click the button again and find the new line of Get /test.txt in Firebug
Status: 200 OK
Response Header:
...
Last-ModifiedTue, 29 Mar 2011 07:53:12 GMT
Cache-Controlmax-age=31536000
ExpiresWed, 28 Mar 2012 10:15:24 GMT
...
This doesn't make any sense. If repeating the above test steps (3 to 6) with IE9 or Chrome, it will get the correct 304 status code in step 6.
Does this mean Firefox browser doesn't cache Ajax calls? No way to cache file such as /test.txt or large.json?