We can manipulate our expire date by putting this on our .htaccess
ExpiresDefault "access plus 10 years"
We want this to be manipulated inside our PHP file. While searching for a something like it. I came across with:
$offset = 60 * 60;
$expire = 'expires: ' . gmdate ('D, d M Y H:i:s', time() + $offset) . ' GMT';
header ($expire);
But this only add time 开发者_开发问答to our expire date. For us; we want the year to change. Is there a way to this in php?
You could do this:
$expire = 'Expires: ' . gmdate('D, d M Y H:i:s', strtotime('+10 years')) . ' GMT';
header($expire);
I'm using strtotime
to create a timestamp of the current time + 10 years.
You are doing it right. Just increase offset to be 10 years in seconds.
In order to set expiration date to one year ahead you need bigger $offset, current is only hour (60 seconds in a minute * 60 minutes in hour).
$offset = 365*24*60*60;
精彩评论