search
HomeBackend DevelopmentPHP TutorialPage staticization, page static_PHP tutorial
Page staticization, page static_PHP tutorialJul 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
如何在Word中复制页面如何在Word中复制页面Feb 20, 2024 am 10:09 AM

是否要复制MicrosoftWord中的页面,并保持格式不变?这是一个聪明的想法,因为当您想要创建特定文档布局或格式的多个副本时,在Word中复制页面可能是一种有用的节省时间的技术。本指南将逐步引导您在Word中复制页面的过程,无论是创建模板还是复制文档中的特定页面。这些简单的说明旨在帮助您轻松地重新制作页面,省去从头开始的麻烦。为什么要在MicrosoftWord中复制页面?在Word中复制页面非常有益的原因有以下几点:当您有一个具有特定布局或格式的文档要复制时。与从头开始重新创建整个页面不同

处理Laravel页面无法正确显示CSS的方法处理Laravel页面无法正确显示CSS的方法Mar 10, 2024 am 11:33 AM

《处理Laravel页面无法正确显示CSS的方法,需要具体代码示例》在使用Laravel框架开发Web应用时,有时候会遇到页面无法正确显示CSS样式的问题,这可能会导致页面呈现不正常的样式,影响用户体验。本文将介绍一些处理Laravel页面无法正确显示CSS的方法,并提供具体的代码示例,帮助开发者解决这一常见问题。一、检查文件路径首先要检查CSS文件的路径是

3秒跳转页面实现方法:PHP编程指南3秒跳转页面实现方法:PHP编程指南Mar 25, 2024 am 10:42 AM

标题:3秒跳转页面实现方法:PHP编程指南在网页开发中,页面跳转是常见的操作,一般情况下我们使用HTML中的meta标签或者JavaScript的方法进行页面跳转。不过,在某些特定的情况下,我们需要在服务器端进行页面跳转。本文将介绍如何使用PHP编程实现一个在3秒内自动跳转到指定页面的功能,同时会给出具体的代码示例。PHP实现页面跳转的基本原理PHP是一种在

如何在iPhone上自定义和编辑待机模式:iOS 17的新功能如何在iPhone上自定义和编辑待机模式:iOS 17的新功能Sep 21, 2023 pm 04:01 PM

待机是iOS17更新中的一项新功能,它提供了一种新的增强方式,可以在手机快速闲置时访问信息。通过StandBy,您可以方便地查看时间、查看即将发生的事件、浏览日历、获取您所在位置的天气更新等等。激活后,iPhone在充电时设置为横向时会直观地进入待机模式。此功能非常适合床头柜等无线充电点,或者在日常任务中离开iPhone充电时。它允许您轻扫待机中显示的各种小部件,以访问来自各种应用程序的不同信息集。但是,您可能希望根据您的偏好和您经常需要的信息修改这些小部件,甚至删除一些小部件。因此,让我们深入

如何快速刷新网页?如何快速刷新网页?Feb 18, 2024 pm 01:14 PM

页面刷新在我们日常的网络使用中非常常见,当我们访问一个网页后,有时候会遇到一些问题,比如网页加载不出来或者显示不正常等。这时候我们通常会选择刷新页面来解决问题,那么如何快速地刷新页面呢?下面我们就来探讨一下页面刷新的快捷键。页面刷新快捷键是一种通过键盘操作来快速刷新当前网页的方法。在不同的操作系统和浏览器中,页面刷新的快捷键可能有所不同。下面我们以常见的W

重新排列、禁用和删除 iPhone 主屏幕页面的方法重新排列、禁用和删除 iPhone 主屏幕页面的方法Nov 29, 2023 am 08:22 AM

在iOS中,Apple允许您禁用iPhone上的单个主屏幕页面。还可以重新排列主屏幕页面的顺序,并直接删除页面,而不仅仅是禁用它们。这是它的工作原理。如何重新排列主屏幕页面触摸并按住主屏幕上的空格可进入抖动模式。轻点代表主屏幕页面的圆点行。在显示的主屏幕网格中,轻触并拖动页面以将其相对于其他页面重新排列。其他人会移动以响应您的拖拽动作。当您对新排列感到满意时,点击屏幕右上角的“完成”,然后再次点击“完成”以退出抖动模式。如何禁用或删除主屏幕页面触摸并按住主屏幕上的空格可进入抖动模式。轻点代表主屏

Word删除一页内容的方法介绍Word删除一页内容的方法介绍Mar 26, 2024 am 10:06 AM

标题:Word删除一页内容的方法介绍在使用MicrosoftWord编辑文档时,有时会遇到需要删除某一页内容的情况,可能是想删除文档中的一页空白页或者某一页不需要的内容。针对这种情况,我们可以采取一些方法来快速、有效地删除一页内容。接下来,将介绍一些在MicrosoftWord中删除一页内容的方法。方法一:删除一页内容首先,打开需要编辑的Word文档。定

利用ThinkPHP6实现漂亮的404页面利用ThinkPHP6实现漂亮的404页面Jun 20, 2023 am 11:06 AM

随着互联网的日益发展,许多网站或应用也逐渐变得复杂。当用户在使用时,时常会遇到错误页面,其中最常见的就是404页面。404页面指访问的页面不存在,是常见的错误页面。而对于网站或应用来说,一个漂亮的404页面能极大提升用户体验。在本文中,我们将会介绍如何利用ThinkPHP6快速实现一个漂亮的404页面。创建路由首先,我们需要在route文件夹中创建一个err

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),