The Helper home (www.bkjia.com) tutorial now receives a task to create a blog module for a company, requiring full static. That is, not only the blog homepage is a static page, but other sub-pages must also be static, which can make the website safer and reduce the server load and faster access speed!
Since we have previously created websites that generate static pages, we have some ideas for generating static pages. First, we need to create some subpage templates. When posting a blog post, we will generate the corresponding HTML page through the template of this page, which will fix the content of the article and the posting date, and save the address of this page to the database. The number of comments and views in other articles are captured through AJAX in subsequent request pages. There is no problem with this, but I am confused about the blog homepage! In fact, you can update the HTML file of the home page when publishing an article, but because you need to display the number of views and comments on the blog home page, do I have to update the number of views and comments on the homepage HTML page when I access an article or comment? In this way, the static advantage is reduced. Even if you can read these views and comments through AJAX in the same way as on a subpage, you do not know how to replace placeholders when many articles are involved.
Do you have any ideas or demos? Thank you for your answers ~~
The reply content is as follows: You can try to cache the home page and directly modify the data in the cache when there is an update. After a while, update the database. The use of static pages is nothing more than for performance. It does not seem to be very effective for security. Using the cache can meet the performance requirements, and I think the cache is even better than the performance of static pages. After all, the READ memory is faster than the read hard disk. |