Home MiscellaneousHow Can mod_expires Speed Up Your Website in Apache?

How Can mod_expires Speed Up Your Website in Apache?

by SupportPRO Admin

The time that web pages take to load increases because static resources must be downloaded over the network. These resources can be cached by the browser using HTTP caching. Once a resource is cached, the browser loads the stored copy instead of downloading it again, reducing page load time.

Browser caching helps reduce the total payload size, saves bandwidth, and eliminates repeated HTTP requests for the same resources.

Cacheable resources include JavaScript and CSS files, image files, and other binary objects such as media files and PDFs. HTML files are usually dynamic and should be cached carefully, typically for shorter durations.

In Apache, browser caching is handled using the mod_expires and mod_headers modules, which control cache behavior through HTTP headers sent by the server.

Example Apache Expires Configuration

<IfModule mod_expires.c>
ExpiresActive On

ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”

ExpiresByType text/css “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”

ExpiresDefault “access plus 2 days”
</IfModule>

Explanation

  • ExpiresDefault “access plus 2 days” sets a default cache duration of two days for all content types
  • ExpiresByType image/jpeg “access plus 1 year” tells the browser to cache JPEG images for one year
  • Static files that rarely change can be cached for longer periods
  • Frequently updated resources should have shorter expiration times

By properly configuring browser caching, you can significantly improve website performance and user experience.

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

You may also like

Leave a Comment