Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The cache option of jQuery .ajax doesn't work in Firefox and Chrome?

Tags:

jquery

ajax

I have already set the option 'cache: true', but the cache seems only work in IE, but not in Firefox and Chrome. Is that a known issue?

like image 560
silent Avatar asked Nov 03 '10 05:11

silent


People also ask

Does jquery work in Firefox?

Bookmark this question.

Do browsers cache jquery?

By default most file will be cached however the duration of the caching depends on the header setting for the file. So yes it should be cached with a default setup.


1 Answers

The cache option isn't a special cache that jQuery maintains, so maybe it's a bit of a misnomer.

  • cache: false appends a timestamp to the URL being requested, so it forces the browser to grab a fresh copy, it's more of a cache-breaker.
  • cache: true does nothing, the native browser caching is left to do whatever it's going to do here.

It's not a jQuery specific thing at all, it's just how different browsers choose to cache a response or not. If your cache headers are set correctly telling the browser to cache it, then it should. However, IE likes to cache the hell out of requests even when there are no header instructions to do to...that's likely the behavior you're seeing. If it's the behavior you want though, add the cache control headers (see the link above) to your pages you want cached in other browsers as well.

like image 145
Nick Craver Avatar answered Oct 04 '22 18:10

Nick Craver