Home > Web Front-end > JS Tutorial > body text

Why Does Safari Cache POST Requests in iOS 6 Despite \'cache:false\'?

DDD
Release: 2024-11-03 21:12:03
Original
206 people have browsed it

Why Does Safari Cache POST Requests in iOS 6 Despite

Caching Conundrum: Safari's Selective Fetching in iOS 6

Since iOS 6's release, developers have encountered an unexpected behavior in Safari's web view: $.ajax POST calls are being obstinately cached despite cache:false settings. Intriguingly, this anomaly only manifests when the called function employs a static signature.

Preliminary investigations revealed that Safari caches POST responses only if they lack Cache-Control or Expires headers or if Cache-Control is set to max-age=0. However, granting the request "Cache-Control: no-cache" bypasses this behavior, preventing caching altogether.

Apple's decision to leverage this HTTP specification provision for POST methods (section 9.5) has left developers bewildered. While caching POST responses is not unheard of, Safari's choice to do so without any headers or with max-age=0 seems to be a deviation from conventional browser behavior.

To resolve this caching quandary, a global solution within an Apache configuration is as follows:

Header set Cache-Control "no-cache"
Copy after login

However, if selectively applying the "no-cache" directive to only POST requests is preferred, Apache offers a solution:

SetEnvIf Request_Method "POST" IS_POST
Header set Cache-Control "no-cache" env=IS_POST
Copy after login

Alternatively, adding a unique parameter to the URL or POST data can circumvent the caching issue for static function signatures.

The above is the detailed content of Why Does Safari Cache POST Requests in iOS 6 Despite \'cache:false\'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template