Skip to main content
Legia

Website & UI/UX

What is a Cache?

Also called caching, web cache.

Short definition

A cache is temporary storage for copies of frequently requested data or files, in the browser, a CDN, or a server, so later requests can be served faster without fetching or reprocessing them from the original source.

Cache layers on a website

The browser stores files such as images, CSS, and JavaScript so they are not downloaded again on the next visit. A CDN stores copies of pages on servers close to visitors. On the server, a page cache stores rendered output so pages are not rebuilt from the database on every request, and an object cache stores the results of frequently used queries.

Example in a company

A CMS-based company website slows down every time an email campaign brings in hundreds of visitors at once, because every visit triggers database queries. After a page cache and a CDN are set up, most visitors are served from ready-made copies. The server is no longer overwhelmed, and pages load faster. Server costs also stay more predictable, because a traffic spike no longer translates directly into a spike in database load.

Common problems

A cache kept for too long means changes do not show up right away: a new announcement has been saved in the CMS, but visitors still see the old version. That is why storage time should differ by file type, and there should be a procedure for clearing the cache after important updates. Pages that contain personal data, such as a shopping cart or account page, must never be stored in a shared cache, so one user's data is never shown to another.

Related Legia service Website Maintenance Monthly care that keeps your website online, secure, and up to date without an in-house IT team.

Resources