MyBB Community Forums

Full Version: image of the attachment in the post be cached?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I attach an image with mybb attachment function

the image file is not cached and is loaded every time I load the page.

This is a waste of traffic

Can an attached image be cached?
(2018-08-06, 12:23 AM)alstn13178 Wrote: [ -> ]The image url of mybb's attachment ends in php, not ending in png or jpg.


So I do not know if the image is cached. 

image of the attachment in the post be cached?

I am not aware of any images ending in .php. 

.php is a source hypertext file, not an image.
So I do not know if the image is cached. 

image of the attachment in the post be cached?


when I upload image. I get php url.
Ok, do you have the Attachments setup in your AdminCP like it's shown in the screenshot below?

[Image: afbd25251a7df9c738bdf7e9267bf6c5.png]
yes I have it
(2018-08-06, 01:00 AM)alstn13178 Wrote: [ -> ]yes I have it

One of the MyBB experts should be able to assist you. 

I am not certain what else it can be.
Compared to imgur,
uploaded Images with mybb attachments are loaded every time when I click F5. Not cached


$img = $mybb->settings['uploadspath']."/".$attachment['attachname'];

$time_up = $attachment['dateuploaded'];
$etag=md5($time_up.$img);
$time=gmdate('r', $time_up);

header('Last-Modified: '.$time);
header("Cache-Control: must-revalidate");
header('Expires: '.$time);
header("Etag: ".$etag);

I seem to have found a way.
Attaching this header to image in attachment.php will cache it.