Server side caching for large websites
What is web application caching?
Server side cache is web based software component that allows saving and reading temporary information that takes a long time to compute.
Such technology is used to improve website speed:
- During first request information is generated and stored to cache files.
- During following requests data is simply loaded from website cache, bypassing computing.
To speed up dynamic website data caching mechanism must be equipped with some kind of destructor that would delete cache data when website has been changed; otherwise it would prevent latest information from being displayed.
Such mechanism adds expiry date to cache file; cache is recalculated if sever date surpass cache date.
Expiring cache is very useful for web applications that contact 3rd party server to receive data that changes continuously.
Let's say we are building weather plugin that contacts weather server to get forecast for 7 days. It takes somewhere 0.5s to 3s to contact weather station, so if we would have an application that waits for weather data with each request our website would slow down to weather server response time.
By using expiring cache we have to contact weather server only once a day with first request, further requests are retrieved from website cache in less than 0.01s
Persistent caching provides best performance for internal server computing. Functions that provide server side website update, also delete cache files so they are reloaded only if information is changed.
What do we store in web cache?
Cache engine is used to store a set of variables depending of what are the slow parts of the system. Let's say we need to display database table: we can cache database records (SQL cache) or whole HTML code (buffer cache) as a variable.
Caching database records
We can cache database records needed for our table, so that database server would be contacted only when database is changed.
If we choose to store whole HTML code as a variable we might gain a bit of website speed but our table might lose flexibility if we need to display some dynamic content in one of the cells.
Buffer is very useful to display complex navigation menus as their computing requires more than one database call.
Caching technology in Smooth Step CMS
We took advantages of different caching technologies and implemented them to our content management system. It uses expiring cache to display weather forecasts, persistent cache for website and CMS output.
Database records and buffer arrays are both used to achieve best possible website performance. Caching technology allows us to develop large websites (might contain thousands of pages) that load fast.
Post a comment
Here you can share your thoughts with us by posting a question/comment. Your e-mail will not be shown to protect your privacy. Required fields are marked with *