JSP solves cache Problems

Source: Internet
Author: User

JSP cache problems. this problem has been found many times online. in fact, the answer is similar, that is, how to set it to clear the cache or not to use the cache. no matter what cache. of course. you can use the following methods to solve the problem. images. page. it's just that the place is correct. next we will analyze it slowly.

<% <Br/> response. setheader ("Pragma", "No-Cache"); <br/> response. setheader ("cache-control", "No-Cache"); <br/> response. setdateheader ("expires", 0); <br/> %>

First, let's talk about how to clear the cache. In fact, we all know the method.

Response. setheader ("Pragma", "No-Cache"); <br/> response. setheader ("cache-control", "No-Cache"); <br/> response. setdateheader ("expires", 0); <br/> .....

And so on. Why can't many people say this? The reason is that you put the wrong place. At the beginning, I didn't know why this problem occurred. After finally putting the right place, I realized that it was the wrong place. many people say that they should put it under JSP. In fact, we need to divide the situation here. If you are a pure page, there will certainly be no problem, but what if there is reference to other places? For example, a graph is drawn like me, but other variables are used in the drawing area. At this time, a problem occurs. Before this drawing, clear the cache.For example, if I use writeresponse (response, list, title); To draw a picture, call the above three methods before this. The problem is solved, OK.

 

Second, you don't need to cache it. In fact, when you call it, you can use a random number to set a parameter for it, so that the same page will not be generated continuously, (The same continuous occurrence probability can be imagined. Haha, congratulations when it's in progress .)
For example, when you call an image.

/>

The following parameter is added, so no problem occurs,

 

In fact, as long as the problem is identified, the online answers can basically solve the problem. Why cannot it be solved? Because you did not find your location, the problem was found, and the root cause of the problem was not found.

 

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.