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?
Bookmark this question.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With