What is the Ajax,ajax scenario where the cache is generated and how does the cache problem be resolved? Some places in the project do not recommend using Ajax, why?

Source: Internet
Author: User
The full name of Ajax is asynchronous JavaScript and XML (asynchronous JavaScript and XML). Able to implement partial refresh page.
The situation that generated the cache:
After the success of the data sent by Ajax, the requested URL and the returned response results are saved in the cache, and the next time Ajax sends the same request, it takes out the data directly from the cache, in order to improve the response speed and user experience of the page. Currently this requires two request URLs to be identical, including parameters. At this point, the browser will not interact with the server.
To resolve the caching scheme:
The most effective way to solve this problem is to prevent page caching, and there are several ways to deal with it:
1, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("Cache-control", "No-cache");
2, in the service End plus header ("Cache-control:no-cache, must-revalidate");
3, in the AJAX send the request before adding Xmlhttprequest.setrequestheader ("if-modified-since", "0″);"
4, after the Ajax URL parameters plus "? fresh=" + math.random (); Of course, the parameter fresh can be arbitrarily taken.
5, the fifth method is similar to the fourth, after the URL parameter plus "? timestamp=" + New Date (). GetTime ();
6. Replace get with post: not recommended
Use NOT recommended:
1, Ajax does not support the browser back button.
2. Security issues Ajax exposes the details of interacting with the server.
3, the search engine support is weaker.
4, the failure of the program's abnormal mechanism.
5, not easy to debug.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.