> ## Documentation Index
> Fetch the complete documentation index at: https://kb.stablepoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Hosting Performance Tweaks: Opcode Caching, Expires Headers, and Gzip Compression

There are several hosting features you can use to increase your website's performance. This article covers three of them: opcode caching, expires headers, and gzip compression.

## Opcode caching

PHP is an interpreted language. When a PHP script runs, the interpreter compiles the source code into opcode, and then executes it. Opcode caching stores the compiled opcode in memory, so subsequent requests for the same script skip the compilation step entirely. This can significantly speed up PHP applications like WordPress.

Our servers support **OPcache**. To enable it for your account:

1. Log in to cPanel.
2. Go to **Select PHP Version** (or **MultiPHP INI Editor**, depending on your server).
3. In the extensions list, enable **opcache**.

After enabling OPcache, most PHP applications see an immediate performance improvement with no code changes.

<Note>
  When developing and making frequent changes to PHP files, cached opcode can serve stale versions of your scripts for a short time. OPcache re-validates files periodically, but if you need changes visible instantly, you can temporarily disable OPcache while developing.
</Note>

## Expires headers

Expires headers tell browsers how long they can cache static resources (images, CSS, JavaScript) before requesting them again. With proper expires headers, repeat visitors load your site much faster because their browser reuses locally cached files.

To add expires headers, edit the *.htaccess* file in your site's document root and add:

```text theme={null}
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
```

Adjust the durations to suit how often you change these files. If you version your assets (for example, style.css?v=2), you can safely use long durations.

## Gzip compression

Gzip compression reduces the size of text-based resources (HTML, CSS, JavaScript) before they are sent to the browser, often by 60-80%. Smaller transfers mean faster page loads, especially on slower connections.

To enable gzip compression, add this to your *.htaccess* file:

```text theme={null}
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/json
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
```

<Note>
  Already-compressed formats such as JPEG, PNG, and video files should not be gzipped — it wastes CPU for little or no size reduction.
</Note>

## Testing your configuration

After making these changes, you can verify them with tools such as:

* [GTmetrix](https://gtmetrix.com) — checks expires headers and compression as part of its report
* [Google PageSpeed Insights](https://pagespeed.web.dev) — overall performance scoring
* Browser developer tools (Network tab) — check the Content-Encoding: gzip response header

If you need help enabling any of these features, our support team is available 24/7.
