When we talk about a webpage, it is easy to assume that the webpage in question is made up on one large file. Often this is not the case and a website is made up of a combination of small files of 2 different types – static and dynamic. I will go on to say a little about each type of file but in essence a static file is just that – static i.e. stays as it is and doesn’t change. A dynamic file is capable of changing its output based on what is being inputed into the file.
Static content is content that does not change, every time a static file is downloaded it will always remain the same. As a result a static file is much easier to cache than a dynamic file and uses up much less resources when it is being accessed by a visitor. Some examples of static files/content are: –
These files remain the same once produced and very rarely change, a general rule of thumb I would go by is to try and make your website as static as possible. If your website is made up of predominantly static components it will load and run a lot quicker.
Dynamic content changes based on input, a good comparison would be to compare dynamic content to algebraic subjects – lets say I wrote a webpage that functions as a basic calculator, I would need to take input (a) and input (b) then I would need to write a script to say “tell me what (a) plus (b) amounts to..” (of course this is highly simplified). I can’t cache the page as I don’t know what the values of (a) and (b) are…as you can probably guess this would take up a lot more resources than a static file and put more stress on a server. Although this makes dynamic files/content sound like a drawback they are an essential component of a modern website, especially a website that needs to relay a stream of constantly changing information back to a user (think travel websites, booking a flight or a train etc). A lot of websites such as this use dynamic content that is often stored in a database (or in a similar format), a simple example of this is our Knowledgebase section here at Peters Web, one file is responsible for generating all of the articles at any one time. This illustrates how useful a dynamic file can be as although it commands more processing effort/time, only one file is required to fetch any of the articles requested from our Knowledgebase.
Although dynamic content is extremely useful it is harder to cache than static content due to its changeable nature, however it is worth noting that in the right context caching is possible. Going back to the calculator example, lets say a user enters the sum ‘1+1’ we could then run the script and cache the output (which is 2 just in case you were wondering…..). This is possible as ‘1+1’ is always going to equal 2 thus nothing needs to be recalculated once you have arrived at this answer.
Some examples of dynamic content are: –
As another general rule of thumb, if a user needs to log in to view dynamic content its advisable not to cache the information. This is due to the fact that a cache copy made be produced and another user could potentially end up with a copy of the users information.
I have mentioned caching quite a bit during this article please follow this link to my article that explains a little bit more on the subject of caching.
This is just a short introduction to the subject as usual, if you would like more information on this subject please contact us via a support ticket to our hosting department (open a ticket) and we will get back in touch as soon as possible.
Powered by BetterDocs
Save my name, email, and website in this browser for the next time I comment.