http - Is caching in browser automatic? -
i have javascript app sends requests rest api, responses server have cache headers (like etag, cache-control, expires). caching of responses in browser automatic, or app must implement sort of mechanism save data?
an ajax request no different normal request - it's get/post/head/whatever request being sent browser, , handled such. confirmed here:
the http , cache sub-systems of modern browsers @ lower level ajax’s xmlhttprequest object. @ level, browser doesn’t know or care ajax requests. obeys normal http caching rules based on response headers returned server.
as per the jquery documentation, caches can invalidated in @ least 1 usual way (appending query string):
cache (default: true, false datatype 'script' , 'jsonp')
type: boolean
if set false, force requested pages not cached browser. note: setting cache false work correctly head , requests. works appending "_={timestamp}" parameters. parameter not needed other types of requests, except in ie8 when post made url has been requested get.
so in short, given same headers, ajax responses cached same way other requests.
Comments
Post a Comment