Working with htaccess is a new capitol for me. I have already read about mod_expires here https://httpd.apache.org/docs/current/mod/mod_expires.htm, but I’m stil confused.
I have the next code from stack overflow:
ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType text/html "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType text/x-javascript "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access plus 2 months"
My questions are:
-
I suppose the line
ExpiresByType image/jpg "access 1 year"
tells the client (browser) to download the file and keep it for one year. And when the client accesses the same page from my website, the jpg image won’t be downloaded from my website. It will be read from his computer (where the browser saved first time). After one year, the browser automatically deletes the file and, once the client access my website, it will download again, for another year. If the client cleans his browser history after 2 months, then the browser will download it again even if a year hasn’t passed. Do I miss something ? -
What cache availability should I set for each file type ? It depends on the file ? What should I consider when set the expiration time ?
-
What’s the difference between
"access 1 year"
and"access plus 1 year"
? -
Does
ExpiresDefault
rule works forphp
files too ? I mean, if I have a contact.php file with some content and I modify the content of contact.php, because ofExpiresDefault
rule, the content won’t change to the user ? -
Do search engine spiders listen for this cache rules or they download the files each time they crawling my website ?
-
Is it true that
ExpiresDefault
is for the files I don’t set usingExpiresByType
? If the answer is yes, what are the other types ? What types of files are included here ? -
Do I understand correct that
Header set Cache-Control "max-age=290304000, public"
is the maximum time allowed for a file to be cached ? If the answer is yes, then means that"access 999 years"
will take no effect as long290304000
is the limit. True or false ?