How to do nginx php not cache files

WBOY
Release: 2023-05-21 16:09:18
forward
1409 people have browsed it

How to set up nginx php not to cache files: 1. Find and open the nginx configuration file; 2. Pass "location ~ .*\.(gif|jpg|jpeg|png| bmp|swf|js|css)${add_header Cache-Control no-store;}" can be used to disable caching.

nginx php How to do not cache files?

Nginx cache-disabling configuration

When debugging website programs, browser cache problems often occur, causing modifications to the front-end code to not work. The cache can be cleared only after forcing a refresh via Ctrl F5 each time. At this time, if you disable the nginx cache, you can reduce some minor troubles and allow the browser to request files from the server every time instead of reading cached files in the browser.

After the program is debugged and goes online, you can turn on nginx cache to save the server's bandwidth traffic, reduce some requests, and reduce the pressure on the server.

Achieve the switch effect by configuring the nginx configuration file /usr/local/nginx/conf/nginx.conf

1. Enable cache

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
  #设置缓存上面定义的后缀文件缓存到浏览器的生存时间
  expires   3d;
}
Copy after login

2. Disable cache

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
 #禁止缓存,每次都从服务器请求
  add_header Cache-Control no-store;
}
Copy after login

What are the characteristics of php

1. Fast execution speed.

2. It has good openness and scalability.

3. PHP supports a variety of mainstream and non-mainstream databases.

4. Object-oriented programming: PHP provides classes and objects.

5. Fast version update.

6. It has rich functions.

7. Scalability.

8. Comprehensive functions, including graphics processing, encoding and decoding, compressed file processing, xml parsing, etc.

The above is the detailed content of How to do nginx php not cache files. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!