search
HomeBackend DevelopmentPHP TutorialPage staticization, page static_PHP tutorial

Page staticization, page static_PHP tutorial

Jul 12, 2016 am 08:59 AM
memcacheseooptimizationMemoryLargetechnologyservercachenetclusterstaticpage

Page staticization, page static

Optimization technology for large websites:

1, SEO, one kind of optimization,

2, page Static

3, memcache (memory cache)

4, server cluster technology





Overall goal: improve the website Access speed, SEO purpose: improve website ranking, (the solution is speed)

SEO: Google’s optimization, Baidu’s optimization:



Today, start with the page In terms of staticization:

Let’s talk about a few concepts first:

1. Static URL

Pure html document

http://localhost/dir&file /var.html

But don’t think that the suffix is ​​html is a static website,



2, dynamic URL (website)

localhost/dir&file /var.php?name=admin&id=2

Display different results according to the different parameters passed by the user in the address bar



3, pseudo-static URL

Pseudo-static:

In TP framework, several url modes:

1, / pathinfo

2, MVC ?m=&a=

3, rewrite mode: (difference from pathinfo mode: rewriting without entry file)

Modify apache configuration

Add htacess file

tp framework Medium rewrite mode, pseudo-static:

localhost/dir&file/news-id/2/name/admin.html



Why change the dynamic website to static Format:

1, /*1=1*/ Prevent sql injection

2. Dynamic websites are not conducive to SEO, because? The following parameters will change dynamically. When crawled by search engines, I don’t know how to save

, sina.com/index.html index.php?act=index



Principle: Try not to operate the database without obtaining data from the database



How to achieve page staticization:

Classification of page staticization:

1, according to the form:

1, true static

2, pseudo-static

2, according to the range:

1, partial static Words (jquery, ajax)

2. All static



Search engine:

1. Crawl the content of your website, not all at once How about crawling all the content and putting it into one piece

2, but classifying your content and ranking it according to your keywords



How about being SEO friendly?

1. Baidu’s suggestion:

URL length: no more than 255 bytes

When crawled by search engines:

From the homepage Start triggering: when encountering a page, grab its content and save the content,
www.sina.com/index.html

www.sina.com/news/soprt.html

Because the shorter the page is, the earlier it is crawled, the more frequently it is crawled, and the faster it is updated. I think you are good

And the crawling time for each page is limited, and each page is allocated a maximum of 5 seconds.

Of course, the better the website, the higher the ranking, the longer the time allocated



2. The keywords desciption tag of the meta tag is also made for search engines to see

However, SE will roughly classify it based on your keywords and descriptions

You can prevent search engines from crawling the content of our website:

In the web page code

and , add the nofollow attribute! ! If it is a hyperlink, just add

rel="nofollow" to the tag!

(2) robots.txt



Keywords

description



(3) Try not to Use frame frameset in the foreground, you can use it in the background, frame* (because the background avoids search engine crawling)

(4) flash, try to use pictures instead, jquery to do some special effects

(5) For pictures, try to add alt attributes to each picture. When the picture is not displayed, the alt prompt text is displayed first



SEO optimization----







How to achieve page staticization:

Achieved through php's ob cache

Improve ranking

Improve speed

With the emergence of 360 comprehensive search, Baidu advertising is very cautious





1, achieved through php's ob cache

You can test the access speed of the website through tools

apache comes with ab.exe. This tool

can detect the access speed of your website





Before php5.2, the ob cache was turned off by default. After php5.3, the ob cache was enabled by default

In php.ini output buffering

interview : Use development environment: apache2.2.6

mysql version: 5.3





Use php's ob cache to achieve page staticization

1. Cache: smarty cache, ThinkPHP framework cache, PHP ob cache



(1) ob---cache, first buffer the output data into a space

Then display the cached data of this space when displaying

Because there is some header information by default, and then when it encounters echo, the data will be sent to the browser

Because the default header It has been sent to the browser with the echo



Introduction to ob cache

Is there no error message?

The principle of introducing ob cache:

PHP cache:

(1) ob cache

First judge whether to enable ob cache. If you If it is enabled, first put the output data into the ob cache. If you do not enable the ob cache

, then put it into the program cache



(2) Program cache

That is, if the ob cache is not turned on, cache the data into the program first, and then output it uniformly after the echo is completed



Browsers also have cache:

The browser first saves the data and waits until it reaches a certain amount (ie more than 500 MB) before outputting it



How to obtain cached data



1, ob_start() First put the output data into the ob cache first

2, ob_clean() Clear the cache, but not close it

3, ob_end_clean() Clear the cache and also close the cache

4, ob_flush() Output the ob cached data to the program cache

5, ob_end_flush() Output the ob cached data to the program cache and close it ob cache



ob_flush(); //Just output the ob cache data to the program cache

ob_end_flush(); //Cache the ob cache after output Close



flush() will output the data cached by the program to the browser cache

Browser cache: similar to PHP program cache, first output each Output to the program cache, and then display to the browser after the output is completed



PHP’s caching mechanism:

1, ob cache, if ob cache is turned on, the data will be given priority Put it in the ob cache

2. Program cache. If the ob cache is not turned on, cache the data in the program cache



Page staticization case:

News management system:

output_buffering = Off Turn off caching





Talking about the supplementary lesson:

mysql data type:

varchar(32) : How many digits are displayed?

varchar(255) :



How many bytes does a letter or number occupy: utf- 8 2 Chinese characters: 3

gbk All occupy 1 byte



1 varchar The length range represented is between 0-65535 varchar(255)



char fixed-length string: char(255) The number of encoding digits, 255 refers to how many digits are displayed/saved

char() fixed-length, no matter what you store How many, the number of bytes specified by the station





int: The longest is 429. . 15175290987 Ten billion represents 4 bytes

tinyint: 1 byte 0-255 unsigned





myisam: and innodb: difference

1, myisam does not support transactions, innodb supports transactions

2, myisam query speed is faster than innodb,

3, myisam does not support foreign keys, innodb supports foreign keys (mysql The new version already supports foreign keys)



Foreign keys maintain data integrity,

Transactions: a logical set of operations, each unit that makes up this set of operations , either all succeed or all fail

Three major features:

Atomic

Consistency



Complete project, Not all myisam is unified, nor are all innodb, but based on specific business



Problem: The database must be queried every time it is accessed, and the database is frequently operated, causing increased pressure on the server and database. , and the user may not update the news content within

10 minutes, so we do this:

After the first person visits, a static page is generated,

The second Personal, 3, 4 When I visit this page again, the static page is directly displayed



There is a question at this time:

What should I do if the news is unfortunately updated?

1. Judgment





Finally, when you want to add news or modify news, you should generate a static page



Generate a static page when adding news:

After submission, it will be displayed and stored in the database, and then a static page will be generated



Involves template replacement content

Create a template file. When the style is basically fixed but the content is uncertain, first replace the data part with a placeholder

Then, after obtaining the data, replace it

r fopen()

w



fgets() function, read a line of content (just)

fopen() open the document r w

fwrite() writes content to the opened document

feof() tests whether the current document has been read to the end

fclose() be sure to close the document after opening it

file_put_contents() Write content to a file

file_get_contents() Read the content of a file





1, website category

2. Website optimization Baidu’s suggestions for website optimization: 5 points

3. How to detect website performance (access speed)

4. The beginning of ob cache

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1099825.htmlTechArticlePage staticization, page static optimization technology for large websites: 1. SEO, one kind of optimization, 2. Page static 3. memcache (memory cache) 4. The overall goal of server cluster technology: improve...
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.