There are two sides to the implementation of caching: the theoretical and the practical. We will look at the practical side in the next section. First, we would like to expand on the theoretical knowledge about caching already provided in this blog post so that you understand the practical part even better. So far, you know :
Caching resources from your website in the user's browser makes perfect sense because it contributes to a faster loading speed of your website and all subpages.
To ensure that resources stored in the browser cache are up-to-date, webmasters must correctly define caching rules.
Users also have a responsibility: To ensure that data is up-to-date, it is recommended to regularly empty the cache.
When you, as a webmaster, define the eu data rules for caching , it is best to distinguish between three time periods: long-term, medium-term and short-term . You assign each resource to one of these time periods. This ensures that the respective resource is automatically removed from the cache if its timeliness is at risk.
Recommendations: When which resources should be loaded from the cache
To ensure that resources in the browser cache are up-to-date, webmasters should only cache static resources for a long period of time (e.g. one month; one year) . Examples of static resources are JavaScript files and CSS files. Here is an overview of resources suitable for caching:
CSS, HTML and JavaScript
Image files such as JPG, JPEG, PNG and GIF
object files such as videos and PDFs
Take images as an example: the logo of a company or the infographic in an informative article may not change at all or may only change after several years. Images such as logos can therefore easily be stored in the browser cache for a long time , as they remain up-to-date over a long period of time, for example over a year.
Because resources such as CSS, HTML and JavaScript can be stored in the browser cache, the layout of a page can be saved, for example. Saving CSS files in particular has a positive effect on the performance of websites. CSS files can be saved for a period of one month.