Static pages, static pages

Source: Internet
Author: User
Tags website performance

Static pages, static pages

Optimization Technology for Large websites:

1. SEO and Optimization,

2. Static Page

3. memcache (memory cache)

4. server cluster technology

 

 

Overall goal: to improve the speed of Website access, SEO Objective: To improve the ranking of websites (to solve the problem of speed)

SEO: google optimization, Baidu optimization:

 

Today, we will talk about static pages:

First, let's talk about several concepts:

1. Static website

Pure html document

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

However, do not assume that static websites with the suffix html are,

 

2. dynamic website (website)

Localhost/dir & file/var. php? Name = admin & id = 2

Different parameters are passed in the address bar to display different results.

 

3. pseudo-static website

Pseudo static:

The following url modes are used in the TP framework:

1,/pathinfo

2, MVC? M = & a =

3. Rewrite mode: (different from pathinfo mode: fewer entry files are overwritten)

Modify apache configuration

Add an htacess File

Rewrite mode in tp framework, pseudo static:

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

 

Why do we need to change a dynamic website to a static one:

1,/* 1 = 1 */prevents SQL Injection

2. Dynamic websites are not conducive to SEO, because? The following parameters will change dynamically. When the search engine crawls, it does not know how to save them.

, Sina.com/index.html index. php? Act = index

 

Principle: Do not operate the database whenever possible without obtaining data from the database

 

How to achieve static page:

Static Page classification:

1. Follow the form:

1. True or static

2. pseudo-static

2. According to the scope:

1. Local static words (jquery, ajax)

2. All static

 

Search engine:

1. Capture the content of your website, instead of capturing all the content in one brain.

2. You classify your content and rank your content based on your keywords.

 

How can we achieve SEO friendliness?

1. Baidu's suggestions:

Url Length: no more than 255 bytes

Search engine crawling:

Triggered from the homepage: When a page captures its content and stores the content,
Www.sina.com/index.html

Www.sina.com/news/soprt.html

Because the shorter the capture, the more frequent it is, the faster the update, and the better you think.

In addition, each page has a limited crawling time, and each page can be allocated within 5 seconds at most.

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

 

2. the keywords desciption tag of the meta tag is also presented to the search engine.

SE will make a rough classification based on your keywords and descriptions.

You can disable search engines from capturing the content of our website:

Add the nofollow attribute between the webpage Code
Rel = "nofollow!

(2)robots.txt

 

Keywords

Description

 

(3) Try not to use frame framset on the front end, which can be used in the background and frame * (because the background avoids search engine crawling)

(4) use images instead of flash. jquery provides some special effects.

(5) Add the alt attribute to each image as much as possible. When the image is not displayed, the alt prompt text is displayed first.

 

SEO optimization ----

 

 

 

How to achieve static page:

Implemented through php ob Cache

Improve ranking

Increase speed

With the emergence of 360 comprehensive search, Baidu ads are very cautious

 

 

1. Implemented through php ob Cache

You can test the Website access speed by using tools.

Apache comes with the AB .exe tool.

It can detect the access speed of your website

 

 

Before php5.2, the ob cache is disabled by default. After php5.3, the ob cache is enabled by default.

In php. ini output buffering

Interview: Development Environment: apache2.2.6

Mysql version: 5.3

 

 

Static pages using php ob Cache

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

 

(1) ob --- cache: first, buffer the output data to a space.

Then, the cached data of this space is displayed.

This is because some header information is provided by default. When an echo is encountered, data is sent to the browser.

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

 

Ob cache entry

No error prompt?

Introduce the principle of ob cache:

Php cache:

(1) ob Cache

First, determine whether to enable ob cache. If you enable ob cache, first put the output data in ob cache. If you do not enable ob cache

And then put it in the program cache.

 

(2) program Cache

If ob cache is not enabled, the data is first cached to the program, and the echo is complete, and then the output is unified.

 

The browser also has cache:

The browser collects data and outputs the data only when it reaches a certain amount (ie more than 500 MB ).

 

How to obtain cached data

 

1. ob_start () first places the output data in the ob cache.

2. ob_clean () clears the cache, but it is not disabled.

3. ob_end_clean () clears the cache and closes the cache.

4. ob_flush () outputs the data cached by ob to the program cache.

5. ob_end_flush () outputs the ob cached data to the program cache and closes the ob cache.

 

Ob_flush (); // only outputs the data cached by ob to the program cache.

Ob_end_flush (); // disable the ob cache after the output

 

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

Browser cache: similar to the php program cache, each output is first output to the program cache, and then displayed to the browser after the output is complete.

 

PHP cache mechanism:

1. ob cache. If ob cache is enabled, data is preferentially stored in ob cache.

2. Program cache. If ob cache is not enabled, data will be cached to the program cache.

 

Case study of Static Page:

News management system:

Output_buffering = Off disable Cache

 

 

I made a supplementary remark:

Mysql Data Type:

Varchar (32): number of digits displayed

Varchar (255 ):

 

How many bytes a letter or number occupies: UTF-8 2 Chinese characters: 3

Each gbk occupies 1 byte.

 

1 varchar indicates the length range of varchar (255) between 0 and)

 

Char fixed length string: the number of digits encoded by char (255). 255 indicates the number of digits displayed/saved.

Char () fixed length, no matter how much you store, all the specified bytes

 

 

Int: the maximum value is 429... 15175290987 billion bytes indicates 4 bytes

Tinyint: 1 byte 0-255 unsigned

 

 

Myisam: different from innodb:

1. myisam does not support transactions. innodb supports transactions.

2. myisam queries faster than innodb,

3. myisam does not support foreign keys. innodb supports foreign keys (the new mysql version already supports foreign keys)

 

Foreign key to maintain data integrity,

Transaction: A logical group of operations that constitute each unit of this group of operations, either successful or failed

Three features:

Atomic

Consistency

 

For a complete project, neither myisam nor innodb is uniform, but based on specific services

 

Problem: You need to query the database every time you access the database. Frequent operations on the database increase the pressure on servers and databases, and the user may

The news content will not be updated within 10 minutes, so we do this:

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

When the second user visits this page, the static page is displayed.

 

There is a problem at this time:

What if the news is unfortunately updated?

1. Judge

 

 

In the end, static pages should be generated when news is to be added or when news is modified.

 

Generate a static page when adding news:

After submission, the database is displayed and a static page is generated.

 

Template replacement content

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

Then, after obtaining the data, replace it

R fopen ()

W

 

Fgets () function to read a row of content (only)

Fopen () Open Document r w

Fwrite () writes content to the Open Document

Feof () test whether the current document has been read to the end

Close () after opening the document, remember to close it.

File_put_contents () writes content to a file

File_get_contents () reads the object content

 

 

1. Website category

2. Website optimization Baidu's website optimization suggestions:

3. How to detect website performance (access speed)

4. Start with ob Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.