In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the method of setting cache in IIS". In the daily operation, I believe that many people have doubts about the method of setting cache in IIS. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "what is the method of setting cache in IIS?" Next, please follow the editor to study!
Why cache pictures?
To put it simply, the cache can improve the image reading speed by directly accessing the memory, and alleviate the image Ipico bottleneck caused by the high traffic of the site. In many cases, a picture is a kind of static resource that is not updated frequently, and it is typical that reading is much larger than writing, so it fully meets the principle of caching: one write, countless reads. Of course, not all those who meet this point will use caching. For example, it was mentioned in the last Youku Architecture Learning Notes that Youku did not use video caching technology when storing videos for two reasons:
The write () user process space of Squid consumes, and the AIO of Lighttpd 1.5 reads files into user memory, resulting in low efficiency, which is caused by memory locks.
If you are told by Big Brother to remove a video, if it is troublesome in the cache (this is the highlight, O (∩ _ ∩) O)
But overall, for static files such as pictures and videos, it is very suitable for caching. Cache is always the architect's beautiful mistress, .
Research on the Scheme of Image caching
Next, let's focus on exploring the specific scheme to achieve picture cache. the article tries to deepen step by step according to people's normal thinking, from simple to complex, let's take a look, hoping that after reading it can slightly improve your design taste. Fashion design is a process of constant deliberation and running-in, which I believe all programmers and engineers have a deep understanding of. I will explain this piece in two articles. This one first introduces how to set up Http Headers in web containers such as IIS to cache images.
Note: the web container here refers to IIS, Tomcat, or other WEB server software. Let me take IIS as an example.
The cache in IIS is divided into server cache and client cache. For static resources (html, css, js, pictures, etc.), server cache is enabled by default, that is, when we request static resources from the server, the server first fetches files from its memory, and then goes to the hard disk to find them. Sometimes it's annoying to turn on server caching, which we'll talk about later. As the name implies, the client cache caches the resources to be requested on the client. When users request resources, they first find them locally, and then trouble the server if they can't find them. Let's talk about client-side caching first.
1. Client cache
How to set it up? Please look at the picture below.
(photo source)
The figure above shows that the cache module of IIS is enabled, and the expiration time is set to 1 day, that is, within 1 day, users can read the image from their local cache copy without having to download it from the server. Of course, after 1 day, the cache expires and the image will be loaded into the browser cache again after download. Of course, this approach requires you to have the authority to manage IIS, which I think you have scratched the surface as an architect.
How does this work? Don't worry, please listen to me, young man, be patient.
This is mainly controlled by Http Headers, which is the core of HTTP Request and Response, which carries information about client browsers, request pages, servers, and so on. To put it simply, it is an information board for the interaction between the browser and the server, through which the browser informs the server client of relevant information and request information (such as what kind of browser I am, whether I can receive the content of your server gzip, what is the length of the request, whether cache is allowed, etc.) The server uses it to inform the browser server of the relevant information in response to the request (such as server variables, length of return, cookie, etc.). The specific Http Headers content can be found in this article.
Knowing Http Headers, the cache problem can be easily explained. My explanation is as follows: when I took this Http Headers to the server to request an empty teacher's photo, the server extracted the Http Headers and found that the Cache-Control in it was Public, that is, it could be cached. Then the server looked at the cache expiration time set by itself and found that it had not expired yet, so it told me, boy. First find an empty teacher's picture in your local area, and ask me for it if you can't find it. So I went back to look for it and found that there was really an empty teacher's photo. He didn't lie to me. I was so happy.
I don't know if I explain it this way, empty fans. Got it? Whether you understand it or not, I get it anyway! Of course there are inaccuracies. Please point out. Thank you.
2. Server cache
As I said above, server caching in IIS is enabled by default, IIS caches static resources by default for quick reading, and the cache can be updated automatically when static files are changed. But there is a very annoying problem, if I these pictures are a large number (millions of millions) and are real-time updates (such as stock charts), this problem comes, I so many pictures updated, IIS cache has not had time to update (the amount is too TM), so I will visit the pictures for a long time are the old version, which makes stocks I am very annoyed. So since it violates the principle of caching, how can we disable it? The method is definitely not as simple as you think, I suggest you take a look at this article, is to directly modify the MetaBase.xml file, if the server is not familiar with the guy is not dare to touch this file, but the architect of you, this point of pediatrics, ha.
At this point, the study on "what is the method of setting cache in IIS" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.