There are many ways to prevent your page from being cached and in this tutorial guide, we will do just that using .htaccess.
Step 1 – Login into your web server.
Step 2 – Proceed to the following directory /var/www/html and list all the available files.
cd /var/www/html ls -asl
Step 3 – If there is already a .htaccess file, you can open and edit it right away. If there is none, you will need to create a new .htaccess file.
Step 4 – Change the file’s permission so that it is writeable by Apache.
chown apache /var/www/html/.htaccess
Step 5 – Open to edit .htaccess file.
Step 6 – Copy and paste the following codes into .htaccess.
<FilesMatch "\.(html|htm|js|css|php)> FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </FilesMatch>
Step 7 – Save and exit!
.htaccess will now not cache you website.