Browser cache problems encountered when implementing Ajax in ashx

Source: Internet
Author: User

Recently, a function is provided to record the clicks of a user button when a user clicks a button and determine whether the clicks exceed a certain value. Because the page cannot be sent back when you need to click the button, the combination of JS and ashx is adopted. (The. ashx file is used to implement custom HTTP processing in Asp.net.ProgramAnother way to implement a custom HTTP handler is to customize the handler, such as trace. axd. Note: The ASPX page also relies on HTTP processing programs, but it is a complicated HTTP processing program)

However, in the process of using the browser cache, except for the first request to the. ashx file to interact with the background, only the cache value of the first request result will be returned for future requests. The solution is to add the followingCode:

Context. response. cache. setnostore ();

Alternatively, you can add random parameters to the URL of the request. ashx file, so that each request is considered a different request.

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.