2018-10-10, 04:53 AM
Attachments should have expire header, so they are not redownloaded every time for users who visit you forum often.
Attachments are .php, so servers headers for static files are not applied for them, so we should do it ourself with PHP.
Solution:
I was wrong about servers, we can set it "by-type". But we still need to set in manually in case servers are not set properly.
Expires and/or Cache-Control headers
Here (community.mybb.com) attachments are not cached:
Attachments are .php, so servers headers for static files are not applied for them, so we should do it ourself with PHP.
Solution:
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', $_SERVER['REQUEST_TIME'] + 2592000)); // one month: 60*60*24*30=2592000
in /attachment.phpI was wrong about servers, we can set it "by-type". But we still need to set in manually in case servers are not set properly.
Expires and/or Cache-Control headers
Here (community.mybb.com) attachments are not cached:
HTTP/2.0 200 OK
date: Wed, 10 Oct 2018 06:49:22 GMT
content-type: image/jpeg
content-length: 16088
content-disposition: inline; filename="1.jpg"
content-range: bytes=0-16087/16088
content-security-policy: upgrade-insecure-requests; default-src https: data: 'unsafe-inline' 'unsafe-eval'
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 467725893de075d6-ARN
X-Firefox-Spdy: h2
You should set it in mod_expires (.htaccess) or in attachment.php