Skip to content
BeoHosting
BeoHosting
Technical

What Is Cache and How It Speeds Up a Site

BeoHosting Team··9 min read read
What Is Cache and How It Speeds Up a Site

What is cache

Cache is temporary storage for frequently used data. Instead of the server generating a page from scratch every time - reading the database, running PHP, assembling HTML - cached content is served directly from memory or disk. The result is dramatically faster page loading.

Think of cache as a shelf next to the checkout in a store. Instead of going to the warehouse (server) for every product customers frequently request, you keep the most popular items right at hand. In the same way, cache keeps frequently requested pages and resources closer to the user for fast delivery.

Browser cache

Browser cache is closest to the user. When a visitor first opens your site, the browser downloads all resources - HTML, CSS, JavaScript, images, fonts. On a repeat visit, the browser loads these resources from local memory instead of re-downloading them.

How it works

  • Cache-Control header: The server sends a header telling the browser how long to keep the resource. For example, Cache-Control: max-age=31536000 means the browser keeps the file for a year.
  • ETag: A unique identifier of the file version. The browser asks the server "has the file changed since version X?" - if not, the server replies with 304 Not Modified and does not send the content again.
  • Expires header: An older mechanism that explicitly lists the cache expiration date.

Recommended settings

  • Images, fonts, CSS/JS: Cache for longer periods (6 months to 1 year). Use versioning in the file name (style.v2.css) for updates.
  • HTML pages: Short or no browser cache because content can change frequently.
  • .htaccess example: In Apache/LiteSpeed, use mod_expires to set cache rules by file type.

Properly configured browser cache can reduce load time by 60-80% for repeat visits. Google PageSpeed Insights warns if you do not have appropriate cache headers.

Server cache

Server cache stores generated pages on the server to avoid reprocessing them on every request. For PHP sites like WordPress, this is critical because PHP page generation requires more CPU time than serving a static file.

Server cache types

  • Page cache (Full page cache): The entire HTML output of the page is stored as a static file. Subsequent requests get that file directly without invoking PHP. The most effective caching for WordPress.
  • Opcode cache (OPcache): PHP code is compiled to bytecode once and the cached bytecode is used for all subsequent requests. Enabled by default in PHP 8.x.
  • Object cache: Database query results are stored in memory (Redis or Memcached). Especially useful for WooCommerce and sites with lots of dynamic content.
  • Database query cache: The database (MySQL/MariaDB) has a built-in mechanism for caching frequently executed queries.

LiteSpeed Cache

The LiteSpeed server has a built-in cache mechanism that runs at the web server level - it is faster than any PHP-based cache solution. The LiteSpeed Cache plugin for WordPress manages this cache and offers:

  • Automatic page caching with smart invalidation (only what changed is recached).
  • ESI (Edge Side Includes) for partial caching - cache the bulk of the page while dynamic elements (cart, logged-in user) remain uncached.
  • Image, CSS, and JavaScript optimization in the same plugin.
  • A crawler that proactively generates cache before a visitor arrives.

CDN cache (Content Delivery Network)

A CDN distributes copies of your site to servers around the world. When a visitor from Japan opens your Europe-hosted site, instead of the request traveling thousands of kilometers, the CDN serves content from the nearest server - perhaps in Tokyo.

How a CDN works

  • Edge servers: The CDN has a network of servers (edge nodes) in hundreds of locations worldwide. Each holds a copy of your static content.
  • Origin server: Your hosting server is the origin - the source of original content. The CDN periodically checks the origin for updates.
  • TTL (Time to Live): Defines how long the CDN keeps a copy before checking the origin for a new version.

What a CDN caches

  • Images (JPG, PNG, WebP, SVG) - usually the largest resources on the site.
  • CSS and JavaScript files.
  • Fonts (WOFF2, TTF).
  • Video and audio files.
  • Static HTML pages (with some CDNs).

Popular CDN services

  • Cloudflare: Free plan with basic CDN, DNS, and DDoS protection. The most popular choice for small and medium sites.
  • BunnyCDN: Cheaper than most competitors, with good performance and servers in Europe.
  • QUIC.cloud: A CDN optimized for LiteSpeed servers, with integration into the LiteSpeed Cache plugin.

WordPress cache plugins

If you use WordPress, a cache plugin is one of the most important plugins you can install. Overview of the most popular options:

LiteSpeed Cache (recommended for BeoHosting)

  • Runs at the server level - faster than all PHP-based alternatives.
  • Free with all features included.
  • Image optimization, CSS/JS minification, lazy loading - all in one plugin.
  • Requires a LiteSpeed server (which BeoHosting uses).

WP Rocket

  • Premium plugin (59 EUR/year for one license).
  • Works on any server (Apache, Nginx, LiteSpeed).
  • Easiest to set up - good defaults out of the box.
  • Database optimization, heartbeat control, lazy loading.

W3 Total Cache

  • Free with advanced options for experienced users.
  • Supports page cache, object cache, browser cache, CDN.
  • More complex to set up - wrong configuration can slow the site.

WP Super Cache

  • Free, simple, reliable.
  • Built by the Automattic team (creators of WordPress).
  • Fewer options than W3 Total Cache but much simpler to use.

When caching can cause problems

Cache is not always the solution - in some situations, improper caching can cause issues:

  • Dynamic content: Pages that must differ per user (cart, account, checkout) must not be cached.
  • Stale content: If you change a page but the cache does not refresh, visitors see the old content. Proper cache invalidation is key.
  • Debugging: Cache can hide errors - if you test changes and do not see them, you are probably looking at the cached version. Always purge the cache after edits.
  • Personalized content: Sites with A/B testing or geo-personalization must carefully configure cache so different users do not get the wrong version.

Measuring cache effect

To see how much cache improves your site's performance, use these tools:

  • Google PageSpeed Insights: Measures load speed and gives specific caching recommendations.
  • GTmetrix: More detailed analysis with a waterfall diagram showing each request and whether it was served from cache.
  • WebPageTest: Tests from multiple locations and shows the difference between first load (cold cache) and repeat load (warm cache).
  • Chrome DevTools: The Network tab shows the size and load time of each resource and whether it came from browser cache.

Conclusion

Caching is the most efficient way to speed up a site without additional costs. The combination of browser cache, server cache, and CDN can reduce load time by 70-90%. For WordPress sites on BeoHosting, the LiteSpeed Cache plugin is the ideal solution because it uses the built-in server cache for maximum performance. Start by installing the cache plugin, set browser cache headers, and consider a CDN for a global audience. Results are visible immediately - a faster site means happier visitors, better SEO, and more conversions.

BeoHosting Team

10+ years of experience — Web hosting and infrastructure specialists

  • Web Hosting
  • WordPress Hosting
  • VPS
  • Dedicated Serveri
  • Domeni
  • SSL
  • cPanel
  • LiteSpeed
  • Linux administracija
  • DNS

Last updated: