I have set the expiration information for my resources in the .htaccess file as shown below:
If I go to Chrome and use inspect element to look at the one of the images downloading, I see that the caching information is correctly set (as it is with JS and CSS files too) in the HTTP headers:
cache-control: max-age=2592000 content-type: image/jpeg date: Thu, 31 Jan 2019 23:31:13 GMT expires: Sat, 02 Mar 2019 23:31:13 GMT last-modified: Thu, 24 Jan 2019 12:02:22 GMT
However, I have visited my website in the same browser twice today, once yesterday and again the day before, and every time it has re-downloaded the resources again (the
date header entry of the same image I looked at above has changed to the current time (i.e. the image has been downloaded again), but still has an
expires entry of a month in the future).
If I close Chrome and reopen it again, the images are listed as "from disk cache" and the
date header remains as what it was before so it is not failing to cache resources altogether, they're just not persisting for the time I specified.
Why could this be happening and what can I do to fix it?