Pseudo-static technology introduction and advantages and disadvantages analysis (more complete) _ Other comprehensive

Source: Internet
Author: User
Tags error handling servervariables
1, static Web page and dynamic comparison:
1 Static Web page:
Advantages: A, the search engine friendly, the quality is included high; B, access speed, C, resources (CPU, etc.) occupy less.
Disadvantage: A, for a large portal, or for the community, constant modification will result in a large amount of I/O, resulting in fragmentation of the disk and even a bad disk. Quite a horror of a hidden danger. Once the user information is gone, the game is over. B, storage space will be more occupied.
2) Dynamic Web page:
Advantages: Relative to the static, its disadvantage is the dynamic advantages of the location-less space, for hard disk friendly.
Disadvantage: A, not friendly to search engines. The search engine will not include the URL with question mark, because the search engine is afraid to enter the dead loop because of the question mark. Detailed see another reading notes (learning notes-Web search Basics)
B, high concurrency when resources occupy more.

and pseudo-static is in such a background came into being, it in the preservation of the merits of the dynamic, so that the Web site static, that is, so that the Web site without a question mark, cheated the included crawler on the line. This perfectly blends the advantages of the front two.
Advantages: Static advantages + Dynamic Advantages
Insufficient: The flow slightly larger some use pseudo static on the CPU use overload, because the pseudo static is using the regular judgement instead of the real address, to distinguish which page the responsibility also by the direct designation turn by the CPU to judge, so the CPU occupancy rise, is indeed pseudo static biggest malady.

Implementation mechanism: Is the use of server-side, the request of the dynamic page to make changes to allow the browser to think that the access is also a static page, this time, the browser address bar shows the static address information (without question mark).

Two methods of implementation:
1, use isapi_rewrite for dynamic link rewrite HTML static URL. Isapi_rewrite is a DLL component, and Re_write is a module in IIS. This filter implementation is a regular expression, the Dynamic Web site map into a static web site. If news.asp?id=95 can be converted to news/95.html by Re_write. The mapped regular expression is set in the Httpd.ini file.
As a small example: processing data paging, then the writing is:
more_<%=page%>_<%=type%>.html (Note: page is page number of pages, type is data type) representation: more_1_95.html
If the next page is: more_2_95.html, continue to the next page of the loop, then:
More_3_95.html, and so on.
But you need to add the following code to the Httpd.ini file:
Rewriterule/more_ (\d+) _ (\d+) \.html/jsp/more\.asp\?page=$1&type=$2 [N,i] string 9
If your dynamic program has multiple parameters that need to be passed, add more than one (\d+), as follows:
Rewriterule/more_ (\d+) _ (\d+) _ (\d+) \.html/asp/more\.asp\?page=$1&type=$2&type2=$3 [N,I]

Advantages: Basically do not need to do any changes in the procedure. Trouble: To implement this requires control of IIS, so when you rent someone else's server, you need to contact the service provider first. (This is, of course, for the ASP, asp.net do not--directly put the DLL assembly in the program bin and then appropriate configuration can be implemented)

2, IIS 404 error handling mechanism: Through the custom error, to our prepared processing page. However, this kind of scalability needs to be studied, and the overall requirements for procedural processing are high, which is not suitable for practical application.

First, set the site properties-Self-tuning error
Locate HTTP Error 404, and then edit the property-> message type Select Url->url to fill in "/index.asp" or your error-handling page.
This way, for example, when a user or spider accesses the http://tech.todo.net.cn/12345.html (12345 is the article in the database ID). Because some pages do not exist, 404 errors are triggered. turned to index.asp.
In index.asp Riga
Currdomain=request.servervariables ("Http_host") ' Current access domain name
Currurl=replace (Request.ServerVariables ("query_string"), "404;http://" &CurrDomain& ": 80", "") ' Current access URL
This time the Currurl should be: 12345.html.
That way, you get the page that the user is trying to access. And then extract the article ID (should be: 12345), with regular, here is not much to say.
Then go to the database to extract the content of the article. Output to the page, OK.

Conclusion: Pseudo-static is too suitable for the common enterprise Web site-not requiring high concurrency, but also very concerned about SEO (search engine optimization), but also requires the background can be dynamically updated. Of course, it's OK to generate static pages directly, because it's not as big as a community change.

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.