Lets say that i hav开发者_JAVA百科e a php script which "generates" a page, but it does contain "Whiles" and "If" to build that, but lets assume that it will never change. the code itself weight 2 Kbs. Lets say i get the HTML generated from that code and put on example.html which weights 10Kbs. What i should do? Keep the static HTML that weights more than the script? or not? Just remembering the php script values will never change.
Cache the generated page and deliver using gzip compression.
Re-build the cache if and when necessary.
It totally depends on the number of requests you get every day, but in general, it is a good idea to cache things, especially if they never change. Starting a PHP process will cost more memory than serving a static HTML file, even if the file is much larger than the generating script.
So, yes, keep the static HTML and have your PHP script update it sporadically - if at all.
Always use server side code whenever possible, you don't want to go hardcoding static HTML pages because in the future you may have to refactor things around and it'll be much easier if you have loops controlling data - you'd have to update only one portion rather than every single instance in the static HTML. This saves time and money.
You can use gzip compression in Apache. The filesize of the file containing the code is not a huge deal. And nowadays you can cache stuff, so it makes absolutely no sense having static html IMO.
精彩评论