Skip to main content

Speed up your website with caching and compression

Published on July 4, 2026 11 min read

Want to speed up your website? This step-by-step guide shows how caching, compression and image optimisation make your site faster on Plesk hosting.

Flat illustration of a person beside a browser window showing a speed gauge and a rising line, an orange lightning bolt, stacked cache cards and shrinking images, in shades of blue with an orange accent.

A slow website costs you visitors, conversions and rankings in Google. The good news is that you can fix a lot yourself. You can speed up your website with caching, compression and image optimisation, and much of that comes down to the right settings. LJPc already takes care of part of it: compression and PHP OPcache are switched on by default on our servers. This article first explains what caching is and why it makes your site faster. After that, you get a practical, step-by-step plan you can apply straight away, plus tips for measuring your speed.

What is caching and why does it speed up your website?

Caching means keeping a ready-made copy of something that would otherwise have to be calculated or fetched again on every visit. Instead of redoing all the work each time, the server or the browser hands back the stored copy. That saves processing time, data traffic and waiting time, so your page loads faster.

Caching happens in roughly three places.

Browser cache (on the visitor's side)

Your visitor's browser stores static files such as images, stylesheets (CSS) and scripts (JavaScript) locally on their computer or phone. When someone returns or clicks through to another page, the browser takes those files from its own cache instead of downloading them again. With a few lines of code, you decide how long the browser may keep those files.

Server-side cache (on the server)

On the server itself, three layers play a role. It helps to keep them separate.

  • Page cache: the server stores the fully built HTML of a page. The next visitor gets that ready-made page, so PHP and the database do not have to run again. This is mainly what WordPress cache plugins do.
  • Opcode cache (OPcache): PHP keeps the compiled version of your code in memory, so the code does not have to be translated again on every request.
  • Object cache: the results of heavy operations, such as database queries, are kept in memory (for example with Redis or Memcached). This mainly helps with dynamic pages that a page cache cannot store as static HTML.

CDN (content delivery network)

A CDN is a network of servers in different locations around the world. Those servers keep copies of your static files and deliver them from the location closest to your visitor. That way, the data travels a shorter distance, which lowers the load time and takes pressure off your own server. A CDN is optional and mostly useful if you have many visitors from different countries.

Measure your speed first: PageSpeed Insights and GTmetrix

Always start by measuring. That tells you where the gains are and whether a change really helps. Measure before and after every change so you can see the effect.

  • PageSpeed Insights (pagespeed.web.dev) from Google uses the Lighthouse testing tool and combines that with real user data. The tool checks your page against the Core Web Vitals: LCP (load time, good is 2.5 seconds or faster), INP (responsiveness, good is 200 milliseconds or faster) and CLS (visual stability, good is 0.1 or lower). Google judges these scores at the 75th percentile: at least three quarters of your visitors should get a good experience. In March 2024, INP replaced the older metric FID.
  • GTmetrix (gtmetrix.com) is also based on Lighthouse and gives you a clear grade plus a waterfall chart. In that chart, you can see exactly how much time each file costs, so you can spot the biggest culprits.

You can use both tools free of charge for one-off tests. Run a test, note your scores and then get started with the steps below.

Want to see what the server sends along with each file, such as compression and cache settings? Open your browser's developer tools (F12) and choose the Network tab. Reload the page and click a file in the list: the response headers show what the server sends. In the steps below, you use this to check whether a setting works.

Step 1: Set up browser caching via .htaccess

The file .htaccess is a settings file that applies on a per-folder basis. Our servers run LiteSpeed or Apache, and both read .htaccess. You find the file in the httpdocs folder via Files in Plesk, or you edit it over FTP. With a small block of code, you tell the browser how long it may keep files.

  1. First, make a copy of your existing .htaccess, for example by downloading the file. To make a full backup, read back up your website.
  2. Open Plesk from the customer portal (see open Plesk from the customer portal), choose Files and go to the httpdocs folder. Prefer an FTP program? Read upload files with FTP, FTPS and SFTP.
  3. Open the .htaccess file, or create it if it does not exist yet.
  4. Paste the block below at the top of the file and save. If you use WordPress, place the block outside the lines # BEGIN WordPress and # END WordPress: WordPress rewrites everything in between.
  5. Check whether the caching is applied, as described below.
<IfModule mod_expires.c>
  ExpiresActive On

  # Images: keep for a year
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Fonts: keep for a year
  ExpiresByType font/woff2 "access plus 1 year"

  # CSS and JavaScript: keep for a month
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"

  # HTML: do not keep long, as content changes
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

The mod_expires module automatically sends both an Expires header and a Cache-Control: max-age header, so you do not need to set both separately. You can safely let static files be kept for a year, because WordPress and most systems add a new version number to the file name when something changes (for example style.css?ver=2.1). The browser then sees a new URL and fetches the new version. HTML, on the other hand, should be kept for a short time, so visitors see your changes quickly.

Check: in the developer tools, choose the Network tab, reload the page and click an image or a CSS file. If the response headers show cache-control with a max-age, it works. If you see no max-age, the web server of your package does not apply these rules. In that case, contact support. To learn what else you can do with this file, read .htaccess: redirects, security and more.

Step 2: Check compression

Compression shrinks text files such as HTML, CSS and JavaScript before they are sent to the browser. An HTML page often becomes 60 to 85 per cent smaller as a result. There are two methods: the well-known GZIP and the newer Brotli, which usually makes files a little smaller still.

Compression is switched on by default on our servers. The server picks Brotli or GZIP itself, depending on what your visitor's browser supports. So you do not need to add any rules for it to .htaccess.

Check: in the Network tab, click the page itself at the top of the list. The response headers then show content-encoding: br (Brotli) or content-encoding: gzip. Images (JPEG, PNG, WebP) and woff2 fonts are already compressed and usually do not get this header; that is as it should be. If an HTML, CSS or JavaScript file shows no content-encoding, contact support.

Step 3: Optimise your images

Images are usually the heaviest part of a page, so this is often where the biggest speed gains can be made. Keep these points in mind.

  • Right dimensions: do not load a 4000-pixel-wide image into a 400-pixel-wide box. Scale the image to the size at which it is actually shown.
  • Modern formats: save images as WebP. That format is supported by nearly all browsers and is considerably smaller than JPEG or PNG. The even newer AVIF is sometimes smaller still, but WebP is the safe default choice.
  • Compression: a JPEG quality of around 80 per cent gives a small file with no visible loss of quality. Also, remove unnecessary metadata.
  • Lazy loading: with the loading="lazy" attribute, the browser only loads images when the visitor is about to scroll to them. Do not do this for the large image at the top of the page, because you want that one to load straight away.

In WordPress, the latest version already adds loading="lazy" automatically, and many image-optimisation plugins can resize your images and convert them to WebP for you. That way, you do not have to do this by hand.

Step 4: Speed up WordPress with a cache plugin

If you use WordPress, a cache plugin takes a lot of work off your hands. Such a plugin makes a static copy of your pages and often handles browser caching for you as well. Important rule: keep only one page-cache plugin active at a time. Otherwise, they will work against each other.

  • LiteSpeed Cache is the best choice if your site runs on a server with LiteSpeed, as it does on most of our servers. The plugin works together with the cache built into the web server itself, so visitors get a ready-made page without PHP and the database having to run. You can see whether your site runs on LiteSpeed in the Network tab: the page itself then shows server: LiteSpeed. With the page cache on, you see x-litespeed-cache: hit from the second visit onwards: the page came from the cache. On a server without LiteSpeed, the page cache of this plugin does not work.
  • WP Super Cache is made by Automattic, the company behind WordPress.com. You set up the plugin in a few steps, and it creates static HTML pages, so most visitors are served a static page without PHP and the database having to run. A good choice if you want quick results, also when your site does not run on LiteSpeed.
  • W3 Total Cache is more extensive and offers page cache, object cache, database cache, browser caching and the merging of files in one plugin. That power comes at a cost: the plugin has had more than one serious security vulnerability in recent years. If you use it, always keep it updated to the latest version and turn on automatic updates. To learn how to update plugins safely, read update WordPress safely.

After installing, turn on page caching, test your site thoroughly and measure again. Combine the plugin with OPcache on the server (the next step) for the best result.

Step 5: Make the most of PHP OPcache

OPcache is a built-in part of PHP that keeps the compiled version of your code in memory. Without OPcache, PHP translates your code again on every request. With OPcache, that happens only once. For a PHP application like WordPress, that is one of the cheapest and biggest speed gains there is.

The good news: OPcache is switched on by default with every LJPc web hosting package, for all PHP versions you can choose in Plesk. You do not need to do anything for it. What does help is a recent PHP version: newer versions are faster in themselves. Choose the newest PHP version that your plugins and theme support. To learn how and what to look out for, read change the PHP version in Plesk.

Note: OPcache is not the same as an object cache such as Redis. OPcache speeds up the code, while an object cache stores data. They complement each other. OPcache is also set at server level, not via .htaccess.

Still slow? How to get more speed

Have you gone through all the steps and are you still seeing slow load times? Then check these common causes.

Common causes of a slow website and their fixes
SymptomLikely causeFix
Large, slow pageImages that are too heavyResize and compress your images (step 3)
The server responds slowly on every pageNo page cacheTurn on a cache plugin (step 4)
Returning visitors load everything againNo browser cachingSet up browser caching (step 1)
WordPress feels slowAn old PHP version or outdated pluginsChoose a recent PHP version (step 5) and keep WordPress and your plugins up to date
Many separate requestsToo many plugins or external scriptsRemove what you do not use and limit external scripts

A valid SSL certificate helps too: browsers only use the faster HTTP/2 protocol over a secure HTTPS connection, and that loads many files more efficiently at once. If your website grows a lot and you run into the limits of shared hosting, more capacity, such as a dedicated server, gives you room to grow again. After that, measure once more so you know it made a difference.

With these steps, you can already gain a lot of speed on your own hosting. Work from top to bottom, measure the effect each time and adjust where needed. Can't work it out? Call us on +31 85 130 6429 or create a support ticket and we will take a look with you.

Frequently asked questions

What is the difference between browser cache and server-side cache?

The browser cache sits on your visitor's device and stores static files so that a return visit loads faster. The server-side cache sits on the server and stores, for example, the built HTML page or compiled PHP code, so the server has to do less work. They work together: both make sure that less has to be done again.

Do I have to set up caching by hand, or does a plugin do that?

Compression and OPcache are already switched on on our servers. You can set up browser caching yourself via .htaccess. If you use WordPress, a cache plugin such as LiteSpeed Cache or WP Super Cache handles page caching and often browser caching too. In that case, go with the plugin and leave out the manual rules to avoid doing the work twice.

What is the difference between GZIP and Brotli?

They are two ways of compressing text files. Brotli is newer and usually makes files a little smaller than GZIP. Compression is already switched on on our servers: the server automatically picks a method that your visitor's browser supports.

How do I know whether my website runs on LiteSpeed?

Open your browser's developer tools (F12), choose the Network tab and reload the page. Click the page itself at the top of the list: if the response headers show server: LiteSpeed, your site runs on LiteSpeed and LiteSpeed Cache is the best cache plugin for WordPress.

Why is my website still slow after caching?

Caching is a big part of the solution, but not all of it. Often the page still has images that are too heavy, is running an old PHP version, or is slowed down by too many plugins and external scripts. Go through the table above and measure again after every change.

Is OPcache the same as a cache plugin?

No. OPcache works at server level and stores the compiled PHP code, so PHP itself runs faster. OPcache is already switched on on our servers. A cache plugin works inside WordPress and mainly stores the built pages. They complement each other: for the best result, you use both.

How do I measure whether my website has become faster?

Run a test with PageSpeed Insights and GTmetrix before and after your changes and compare the scores. Pay particular attention to the Core Web Vitals (LCP, INP and CLS) and to the total load time. Test a page a few times, because the first measurement after a change may not yet reflect caching.

Prefer to talk to someone?

We are also happy to answer your questions personally. Schedule a free consultation or call us directly. We are glad to think along with you.

Stay up to date with recent developments! Subscribe and receive our newsletter Signing up...