Expires headers tell the end user's web browser how long it should cache various types of content for.
Expires headers are regular HTTP headers, so any method that allows for you to set an HTTP header is a valid method for setting expires headers.
On cPanel the mod_expires Apache module is installed by default, so the method outlined within this guide will make use of the mod_expires method for setting these headers due to the ease of use it provides.
1. Log in to the cPanel account for your website
2. Click on the File Manager icon under the Files section
3. In the upper right corner of File Manager, click on the Settings button
4. Put a check next to "Show hidden files" if it is not already checked and click Save
(This is required for you to be able to see the .htaccess file in File Manager)
4. Locate the .htaccess file for your website within the File Manager, or create one if it does not already exist.
5. Select the .htaccess file and click on the "Edit" button in the toolbar along the top of File Manager
6. If you see a popup asking about the encoding of the file, leave the options at the default and click Edit
7. Paste the following configuration at the bottom of your .htaccess file:
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
8. Click the Save Changes button in the upper right corner
9. Verify that the expires headers are being sent properly. You can do this by manually inspecting them with the steps outlined below:
Or you could also use a service such as GTMetrics to analyze the site: