Home  >  Article  >  Backend Development  >  Detailed explanation of php page staticization examples

Detailed explanation of php page staticization examples

小云云
小云云Original
2018-03-20 13:16:481841browse

This article mainly shares with you detailed examples of static PHP pages, hoping to help everyone.

1. Dynamic page parsing process

Grammar analysis-》Compile-》Run-》 Display results

2. How to optimize the response time of dynamic pages

Staticize dynamic pages; optimize database; use load balancing; use cache

3. Benefits of static dynamic pages

Reduce the calculation time of server scripts and save server resources; reduce the response time of the server and make it faster The response makes the user's physical examination better;

Because the static file displays the results directly

4. How to set the dynamic url to a static url The form


5. What is pseudo-static

Pseudo-static: It looks like a static page, but in fact, the dynamic url is accessed (the dynamic url address is converted into a static page Address)

6. Classification of static pages


##If you want to make static, you must know buffer

7. Understand buffer


Case: Save the file, first write to a buffer

(operating system’s buffer) , when a buffer is full, write the data in buffer to the hard disk

8. PHP buffer process


##Syntax analysis

-》Compile-》When we execute (run) the php program when. First, the #buffer buffer is saved in php. When a buffer is full, the script process will give ## The data in #php buffer is passed to the client through tcpThe buffer of php is in two places Local control:

1. In the configuration file php.ini

##2. Enable ob_start() in the script file

Note: If the buffer is enabled in php.ini, it can still be used without writing ob_start() in the script, because php.ini is the largest and everyone needs it. Listen to him

If buffer is enabled in both

php.ini and the script, then 2 memory cache areas will be opened (the ones in the script should It is a newly opened cache area in php.ini)


##9. Commonly used ob functions


#The last function is equivalent to the

2 and 3 Combine them

##Because he puts it into the buffer first-

tcp-》browser. The buffer has been cleared and tcp has nothing to send, so of course the browser will not display it. 9,

php Implementation ideas for pure static page [easiest]

Idea: Check the data-》Introduce the template file-》Traverse the data in the template file-》Write the template file into a static file


10.

php

Implementation ideas for pure static page [commonly used]


Add one more fear judgment than the above code, and change the function (see Red box)


##11.

phpIdeas to achieve pure static implementation of the page [Overall update]


Idea: The processing logic of clicking to start updating is the same as 9.

Check the data-》Introduce the template file-》Traverse the data in the template file-》Write the template file into a static file

12, php Implementation ideas for pure static page [server scheduled update]

Call the script of 9 or 10 in crontab -e

13. Partially purely static (can be understood as part of it being a dynamic file)

Idea: In template fileWrite ajax

(rather than in index.shtml, because the static file is based on the template file Generated, the static files did not exist when they were not generated, or they were overwritten after they expired). Data queried in ajax request method (Interface)-》Assemble data-》Return data


In this way, when refreshing again, when you go to ajax, it will dynamically load data - "Fill the template -" Generate static files - "Display it to the user

14. PHP handles pseudo-static


#As for apache or nginx to configure pseudo-static, you can go to Baidu Search on the Internet and grab a lot. You can also read my blog. The configuration file is changed on both win and Linux.

Related recommendations:

php Detailed explanation of page static examples

php caching mechanism to realize page static code sharing

PHP page static example sharing

The above is the detailed content of Detailed explanation of php page staticization examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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