Nginx cache files and dynamic files automatic balancing configuration script

Nginx cache files and dynamic files automatic balancing configuration script

nginx

Nginx (engine x) is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP server. Nginx was developed by Igor Sysoev for the second most visited site in Russia, Rambler.ru (Russian: Рамблер). The first public version 0.1.0 was released on October 4, 2004.

Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server released under a BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities are indeed better than those of the same type of web servers. Users of nginx websites in mainland China include: Baidu, JD.com, Sina, NetEase, Tencent, Taobao, etc.

The purpose of the following nginx configuration script is to automatically determine whether there is a cache file. If there is, the cache file will be output first without going through PHP. If not, it will return to PHP for processing and generate the cache file at the same time.

The PHP framework is ThinkPHP, the last rewrite is related, and it can be ignored if it is not based on this framework.

location ~* ^/xx/yy/main.*$ {          
 set $scenic_id 0;           
 if ($request_uri ~* "scenic_id=([0-9]+)") {        
  set $scenic_id $1;          
 }             
 if (-f $document_root/Html/json/$scenic_id.json) {       
  rewrite ^(.*)$ /Html/json/$scenic_id.json last;      
 }            
 rewrite ^/(.*)$ /index.php/$1 last;         
 #try_files @json $uri;          
}

Summarize

The above is the configuration script for automatic balancing of Nignx cache files and dynamic files introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Solution to the unknown directive that cannot be opened due to Nginx configuration file problems
  • Detailed explanation of nginx configuration static file server
  • Detailed configuration of Nginx to use font files across domains
  • Using nginx to provide file download server configuration under Windows
  • PHP website modifies the nginx configuration of the default access file
  • Introduction to Nginx configuration and configuration files under Windows
  • How to configure caching of static files in nginx
  • Detailed description of Nginx configuration file nginx.conf
  • How to use Nginx as a cache server and delete its cache files
  • Nginx upload file full cache solution

<<:  A brief discussion on the concat function in MySQL. How to add a string before or after a field in MySQL

>>:  JavaScript generates random graphics by clicking

Recommend

Common methods and problems of Docker cleaning

If you use docker for large-scale development but...

Native JS realizes compound motion of various motions

This article shares with you a compound motion im...

React High-Order Component HOC Usage Summary

One sentence to introduce HOC What is a higher-or...

How to configure MySQL scheduled tasks (EVENT events) in detail

Table of contents 1. What is an event? 2. Enable ...

In-depth analysis of MySQL deadlock issues

Preface If our business is at a very early stage ...

Detailed explanation of keywords and reserved words in MySQL 5.7

Preface The keywords of MySQL and Oracle are not ...

HTML Basics Must-Read - Comprehensive Understanding of CSS Style Sheets

CSS (Cascading Style Sheet) is used to beautify H...

Sample code for partitioning and formatting a disk larger than 20TB on centos6

1. Server environment configuration: 1. Check dis...

Analyze the usage and principles of Vue's provide and inject

First, let's talk about why we use provide/in...

How to solve the abnormal error ERROR: 2002 in mysql

Recently, an error occurred while starting MySQL....

Detailed explanation of how to enable slow query log in MySQL database

The database enables slow query logs Modify the c...

The latest version of MySQL5.7.19 decompression version installation guide

MySQL version: MySQL Community Edition (GPL) ----...

Docker uses a single image to map to multiple ports

need: The official website's resource server ...