Script Caching with PHP
king your site less accessible to new visitors. Note: A crawler cannot tell the difference between an HTML file’s output and a PHP file’s. They both send the same content type. Therefore, most crawlers simply decide according to the filename and/or if there is a query string in the URL – that is, if the URL contains a "?". This article discusses a procedure for dealing with both of these drawbacks. The article’s script should be sufficient for use under most circumstances – but in particular, small scale Web sites and individual script pages that are only moderately subject to change (dynamics). The Caching Imperative Simply speaking, caching entails storing the output of one or more dynamic scripts into static HTML files. A visitor to your site would be directed to these HTML files rather than to their original dynamic versions. The mechanism for doing so can be described using a Magazine’s Web site as an example. A Magazine’s Web site would likely have a database that contained numerous articles and stories. You would normally have a script (say "show_article.php") that: Receives an article ID number Reads the article’s content from the database Puts it into some kind of HTML template Formats the whole page with navigation links etc... Sends the resulting HTML to the visitor’s browser As such, in the site’s homepage you might have links to current articles coded as follows: <a href="show_article.php?id=123">Cache Article</a> Now, articles tend to be static and you would hope that the site was operating under heavy request loads (because it’s popular!!). Consequently, requests for each article would undergo extensive processing – meaning access database, search article, and display it. Moreover, when you depend on other database information such as layout specifications, then the process would take even longer. Lastly, a search engine’s crawler would not even index the content of your article(s) because the link to the article page |
查看所有评论
