Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the cache expiration time of static files such as Js and Css by Nginx

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "Nginx how to set the cache expiration time of static files such as Js, Css, etc.", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Nginx how to set Js, Css and other static files cache expiration time" it!

Location ~. *\. (js | css | html | png | jpg) ${expires 3D;}

Expires 3D; / / indicates caching for 3 days

Expires 3h; / / indicates caching for 3 hours

Expires max; / / indicates caching for 10 years

Expires-1; / / indicates that it expires forever.

If set to-1, static files such as js, css, etc. return http 304without modification, and return http 200if modified

Http 304The requested web page has not been modified since the last request. When the server returns this response, the web page content is not returned.

Http 200: the server has successfully processed the request, which means that the server has provided the requested content.

=

If you do not want the proxy or browser to cache, add the no-cache parameter

Add_header Cache-Control no-cache

In this way, when the browser F5 refreshes, it returns http 200instead of http 304,

At this point, I believe that the "Nginx how to set Js, Css and other static files cache expiration time" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report