javascript - Regarding calling website page content, is it better to use ajax request to call it, or is it better to use php to generate a static page?

WBOY
Release: 2023-03-02 10:42:01
Original
1053 people have browsed it

I have been doing website development recently and I have some doubts. I would like to ask everyone for advice:

  1. The website uses Imperial CMS. The news section was developed in front of us using php. Each news generates a static page for users to visit;

  2. Another section was developed later, where users post content and others click to view it. However, after clicking in, the content is retrieved from the background using ajax, and then returned to the user;

Which one of these two methods is better?
What I know is that if the first method becomes more and more content will be added to the website later, refreshing the content page in the background will be a waste of time. In the second method, if there are too many visitors, every time Ajax calls may put a lot of pressure on the database.

Reply content:

I have been doing website development recently and I have some doubts. I would like to ask everyone for advice:

  1. The website uses Imperial CMS. The news section was developed in front of us using php. Each news generates a static page for users to visit;

  2. Another section was developed later, where users post content and others click to view it. However, after clicking in, the content is retrieved from the background using ajax, and then returned to the user;

Which one of these two methods is better?
What I know is that if the first method becomes more and more content will be added to the website later, refreshing the content page in the background will be a waste of time. In the second method, if there are too many visitors, every time Ajax calls may put a lot of pressure on the database.

User comments are mainly about whether there is a need for SEO. Otherwise, it is recommended to use ajax. For other users, this is not the most core. The comments may not be loaded and the reading ends here, which wastes bandwidth and traffic.

Also, the smaller the html, the faster it loads.

It is recommended to use static pages for the core content of the website, mainly to consider search engines, and ajax can be used for comments that are not important

Cache technology can be used after the news static page is generated, so that every time the user clicks to view it, if the cache file has not expired, there is no need to generate HTML page loading data through PHP again, which can improve the access speed of the page. Otherwise, the page will be regenerated through PHP. That’s it. Generally, a news information carrier like this cannot change once in a hundred years. You can consider using local cache. For comments and click states that are easy to change, you can load data information through ajax. As for the real-time nature of comments, it depends on you. Specific needs

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template