Browser caching tells a visitor's browser to store copies of your website's images, stylesheets, and scripts on their own device for a set period of time. The next time they visit a page on your site, the browser loads those files from its local cache instead of downloading them again, which makes your pages feel noticeably faster on repeat visits.
You enable it by adding a short set of rules to your website's .htaccess file. This works on standard Apache-based shared hosting, which covers the great majority of ZIPROF hosting accounts.
Find and Edit Your .htaccess File
The .htaccess file lives in your website's root folder (usually public_html). It's a hidden file, so make sure your file manager is set to show hidden files before you look for it.
In cPanel
- Log in to cPanel and open File Manager.
- Click the Settings button in the top-right corner and turn on Show Hidden Files (dotfiles), then click Save.
- Open the public_html folder.
- Right-click .htaccess and choose Edit (or Code Editor).
In DirectAdmin
- Log in to DirectAdmin and open File Manager.
- Enable the option to display hidden files if it isn't already on.
- Navigate to your domain's public_html (or htdocs) folder.
- Select .htaccess and click Edit.
If no .htaccess file exists yet in either panel, create a new file, name it exactly .htaccess (with the leading dot and no file extension), and open it for editing.
Add the Caching Rules
Paste the following at the end of the file, then save it:
<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/webp "access plus 1 year"
ExpiresByType image/svg+xml "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"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
This tells browsers how long to keep each file type before checking the server for a newer version. Images and icons rarely change, so they get a long cache time. Stylesheets and scripts get a shorter one, since you're more likely to update those.
If a step change to your site doesn't seem to show up after you update an image or a CSS file, that's expected: visitors' browsers may still be showing the cached copy until it expires. During active development, use a shorter time like "access plus 1 day" for CSS and JavaScript, then lengthen it once the site is stable.
Confirm It's Working
- Reload your website in a browser.
- Open your browser's developer tools (usually the F12 key) and check the Network tab.
- Click on an image or CSS file in the list and look at the response headers for an Expires or Cache-Control value showing a future date.
If you don't see those headers after saving your changes, double-check that the code was pasted exactly as shown and that the file saved as .htaccess and not .htaccess.txt. If it still isn't taking effect, your account's server module configuration may need adjusting, in which case reach out to your hosting provider's support team.
Browser caching works well alongside other speed improvements like enabling Gzip compression, which reduces the size of files before they're even sent to the visitor's browser.