Websites' static feature

Source: Internet
Author: User
I do not have high requirements on the speed of my website when using static content for blog sites. Usually, it takes up to 10 seconds to open a page. However, I was a little depressed when my blog encountered several recent events, one of which was caused by high resource consumption caused by attacks, and my blog was forcibly shut down by the network administrator. Another reason is that some problems with Google Fonts make loading of all pages delayed after opening. Although I found 360 webguard for asylum later, it was not a long-term solution, and the idea of static website emerged.

I thought that webmasters who have been playing independent blogs for some years should understand what static means. For more information, see AFO of Fangfang Wangzhi yesterday. I would like to explain here that a website similar to Wordpress (a website dependent on a database) displays a page, the backend needs to extract articles, comments, and other data from the database from the request received. The data is sent to the PHP module of the server to synthesize standard-format webpage files, and the webpage files are transmitted to the client for rendering. After the client is rendered, the page we see is displayed. The links that affect the website opening speed mainly include host database performance and the speed at which the PHP module of the host merges webpage files. Bandwidth also has some influence, but considering that personal blogs usually contain some text information and there are not many files, this has little impact.

The so-called static website means to synthesize webpages in advance and there is a temporary warehouse. When there is a request from a visitor, the visitor directly takes out the transfer from the warehouse, and does not need to rush to the rear database and PHP production workshop to "manufacture" the webpage. This greatly improves the response speed of the blog. The disadvantage is that when dynamic information such as the number of articles read and the latest comments are posted on the webpage, the static cache requires additional JS to implement real-time updates, fortunately, the latest plug-ins provide good solutions.

What is the difference between WordPress static and pure static blogs such as Jekyll. In my opinion, a pure static blog does not need a database at all. after a standard-format webpage is generated locally, the uploaded space is OK. Static Wordpress is a web page generated by the service host. comparing static Post-speed performance, pure static websites such as Jekyll are faster. Wordpress depends on the static method. For the WP Super Cache plug-in I am using, if I use the recommended mod_rewrite Cache mode, write the htaccess configuration and adjust the parameters. after the Cache file is generated, the performance comparison is not much different. The disadvantage of a pure static blog is that it cannot support comments. to make comments dependent on third-party services (this means that bloggers cannot freely manage guest messages ). After Wordpress is static, some comments are submitted and the cache is automatically refreshed.

There are a lot of articles on Wordpress pseudo-static on the Internet, even saying that WP Super Cache is not really static, and then introduce other plug-ins that can implement real static. In my opinion, these are all conceptual obfuscation, aiming to promote other static plug-ins. The pseudo-static mode only modifies the fixed link of the article. Currently, it is generally supported by the host, but the fixed link format has no effect on the performance. to put it bluntly, it is still equal to no static mode. Wordpress and pure static blogs are actually two different things that cannot be compared. However, WP Super Cache, as a static plug-in produced by the official Wordpress team, is undoubtedly supported in terms of performance and personalized configuration. It is not really static. it can only be said that the guy doesn't understand it, but also needs to be confused!

WP Super Cache does not have any disadvantages. In general, it has a high threshold. Therefore, it is not recommended for many low-traffic blogs on the Internet. Because the configuration is not good, the effect of discount not to mention, uninstall will also involve htaccess and wp-config.php. In general, it is troublesome. to put it bluntly, if the technology is not home, it may not be helpful if it is difficult. If it is correct, the blog speed will be substantially improved, and the amount of interest you have to pay depends on yourself.

There are many tutorials on the Internet, so I will only give a reminder.

I. ensure that the wp-content directory has read and write permissions, at the same time, ensure that the Wordpress root directory of the wp-config.php and. htaccess file also has write permissions, it is best to back up once the whole site program.

2. after installation and activation, you can first enable the plug-in test. if the prompt is: the page does not match! The timestamp is different or does not exist! This indicates that the cache does not take effect. In this case, you need to check the plug-in or whether there is a conflict with the topic. The check method is exclusion. Stop all other plug-ins before testing, or switch back to the official topic for testing. The source code at the bottom of the page for the Cache to take effect is indicated by the "Cached page generated by WP-Super-Cache on 09:42:42.

Note: Here we will change the official topic to the default topic that has not been modified. Some friends modify the topic themselves, but some added code may be the cause of this problem. You have confirmed that the topic is used before. switch back to the previous topic and carefully check all the files of the topic. Special attention should be paid to files such as functions. php and header. php. Check whether the file contains a function with the compression function, or the PHP ob_start function is incorrectly used. You can search by keyword such as zip or ob_start. After searching, you can first try to block (or delete, back up the code before deletion), and then re-test the cache function (remember to delete the original cache first ).

3. if the plug-in can be enabled properly, the following configuration is started. The recommended mod_rewrite cache mode is enabled first. You can enable the PHP Cache mode if the host does not support it. this mode is not recommended in normal mode. After it is enabled, in the Advanced tab, the recommended configuration is

1. when a new article or page is published or updated, clear the previous cached file. (This option must be deselected. Otherwise, once a new article is published, all the previously cached files will disappear, which will greatly affect the website access speed and SEO effect .)

2. support for mobile devices. (This option can be used to remove the topic. if it is not used, a large amount of unwanted mobile.html and other cache files will be saved. You can select a topic for the mobile phone page .)

3. compress the page so that visitors can browse the page faster. (If the website supports compression, check it. Who doesn't like fast websites? However, it should be noted that some hosts support this function, but after selecting this option, the pre-cache generation will fail consecutively, and the first access to the website homepage will be blank. In short, this is a small problem. Therefore, this item must be cautious)

4. do not cache data for known users. (It is best not to check. Because it is known that users also need to generate and read the cache, it is best to have a cache !)

5. Anonymous known users are allowed to make the content they browsed as cached files. (Select. The principle is the same as above. everything is cache-centric .)

6. when a page has a new comment, only the cache of the page is refreshed. (Select. Otherwise, it would be too hard to refresh the cache of all pages for a comment .)

7. set the "search" page and "feed" subscription page to be excluded. It is a waste of space to activate a cache page for each search.

4. enable pre-cache, check the pre-cache mode, and load the pre-cache immediately. In this way, a static page can be generated for all public webpages, regardless of whether access is activated or not. For personal blogs, we recommend that you set the cache expiration time to 0 to disable cache expiration.

Finally, the plug-in itself also supports CDN. you can consider the configuration when using the Qiniu acceleration service. If you do not want to allow static webpage files to pass through Qiniu, you should also be careful to exclude html and other static webpage files.

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.