这些类型的网站的后端如何工作?

I am building my own torrent site and after doing some research I have noticed that a lot of the sites out there including these two:

Most of the pages are static and are not dynamically generated on the fly (as the pages end in .html). Thinking about it, it makes sense to me, as the site would load a lot faster rather than having to go to the database every time the page is loaded by a user.

Would I be correct in assuming the following?

  • The pages are static.

  • The pages are updated frequently.

  • The pages are generated automatically by a programming language like PHP or any other.

Is the reason for doing this to relieve pressure from the database (which must be very large ) and to make the site load faster for its users?

Take these examples below:

I guess the pages must be static, as the hash isn't put in a GET variable, but it rather points to a specific page. You will notice also there are dynamic elements on the page, such as recent searches (right at the bottom) and available comments.

If what I'm thinking is correct. then how does the website(s) handle updating the page for comments? Does it mean that the page has to be updated as a whole everytime someone posts a comment?

File extensions like .html or .php aren't a reliable indicator that they are static pages. It's common practice to use Apache's mod_rewrite (or equivilent) functionality to give dynamic URL's a more user-friendly appearance.

With large sites like torrentz and bitsnoop, it may also be possible (if not extremely likely) that they are serving static pages - though these static pages will be part of a frequently updated cache.

These pages are most probably not static, the .HTML extension is just UI candy.

As most dynamic websites do, they are probably internally routed to the front controller, which analyses URI of request to calculate proper response - it doesn't matter if identifiers are in query string (?...) or not.

There is brief description of this pattern on wiki: http://en.wikipedia.org/wiki/Front_Controller_pattern

Take a look at frameworks that use it for details. If you use PHP language, take a look at Symfony framework - http://symfony.com/doc/current/quick_tour/the_big_picture.html to see how well structured web applications should be written.