If you’re using WordPress, you can enable mod_expires
and set up caching rules easily using plugins. This method doesn’t require manual server configuration and can help you boost your website’s speed.
Several WordPress plugins can enable mod_expires and set up caching rules. Popular options include: WP Super Cache, W3 Total Cache, WP Rocket, and Hummingbird. For this lesson, let’s focus on W3 Total Cache and WP Super Cache, as they are free and commonly used.
To enable mod_expires
through WordPress plugins, you can set up caching rules without manually configuring the server. This helps to improve your website’s loading speed and overall performance. Here’s how to do it using popular caching plugins for WordPress.
Step 1 Installing W3 Total Cache Plugin
Start by installing and activating the W3 Total Cache plugin. Navigate to the WordPress Dashboard, go to Plugins, then Add New, and search for W3 Total Cache.
Step 2 Enabling mod_expires
With W3 Total Cache
After activation, go to Performance > Browser Cache in the WordPress dashboard. There, you will find an option to enable the “HTTP (Expires) Header” for different content types, such as CSS, JavaScript, and HTML.
Make sure to check the box for each relevant type and configure the expiration settings.
For example, you could set the “Expires header lifetime” to one week for CSS and JavaScript, while setting it to one month for images. Don’t forget to save your settings and purge the cache afterward.
Step 1 Installing WP Super Cache Plugin
Start by installing and activating the WP Super Cache plugin. Navigate to the WordPress Dashboard, go to Plugins, then Add New, and search for WP Super Cache.
Step 2 Enabling mod_expires
Using WP Super Cache
Activate the WP Super Cache plugin. Next, go to the WordPress Dashboard, select Plugins, and then Add New. Search for WP Super Cache, install it, and activate the plugin.
Now, head over to Settings > WP Super Cache > Advanced. In this section, you will find an “Expiry Time & Garbage Collection” area.
Enable the “Cache HTTP headers with expires” option, and set an appropriate expiration time for your content.
For instance, 3600 seconds (1 hour) may work for dynamic content, whereas static files like images could have a longer expiration period. Once you’ve made these adjustments, update the status.
Step 3 Verify That Cache Is Working (Common Step)
Clear your site cache through the plugin’s settings to apply all changes. You can then check the HTTP headers using the developer tools in your browser or online services like GTmetrix. This will help confirm that the “Expires” or “Cache-Control” headers are correctly set.
By following these steps, you can easily enable mod_expires
through plugins like W3 Total Cache and WP Super Cache, optimizing caching rules for better website performance without directly modifying server configurations.