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

Design Story: The Security Guard Who Can't Remember License Plates

<br />In order to manage the vehicles enteri...

Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

Let's take a look at the process of installin...

vue-cropper component realizes image cutting and uploading

This article shares the specific code of the vue-...

JS operation object array to achieve add, delete, modify and query example code

1. Introduction Recently, I helped a friend to ma...

Nexus private server construction principle and tutorial analysis

one. Why build a Nexus private server? All develo...

Detailed explanation of Vue Notepad example

This article example shares the specific code of ...

MySQL stored functions detailed introduction

Table of contents 1. Create a stored function 2. ...

Solution to the problem of eight hours difference in MySQL insertion time

Solve the problem of eight hours time difference ...

Tutorial on installing and uninstalling python3 under Centos7

1. Install Python 3 1. Install dependency package...

Introduction to MySQL statement comments

MySQL supports three types of comments: 1. From t...

Solve the scroll-view line break problem of WeChat applet

Today, when I was writing a small program, I used...

Detailed explanation of MySQL precompilation function

This article shares the MySQL precompilation func...

A complete record of a Mysql deadlock troubleshooting process

Preface The database deadlocks I encountered befo...