How-to: Save lots of bandwidth with attchmnts with these 2 l

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Ideas Centre
Post Reply
Registered User
Posts: 16
Joined: Sat May 26, 2007 8:48 am

How-to: Save lots of bandwidth with attchmnts with these 2 l

Post by Ambis » Sat May 26, 2007 8:55 am

I post this here, since there is no greater scientific proof of this actually working ;)

I noticed that the attachment files are always downloaded again when opening a topic with attachments. I saw the image being re-rendered on the screen every time I opened the topic (and I didn't press F5 at any point, that sometimes makes images to reload).

So, I made this two line hack to download.php file:

Line 260, before:

Code: Select all

		send_file_to_browser($attachment, $config['upload_path'], $display_cat);
Add the following:

Code: Select all

		header("Cache-Control: must-revalidate");
		header("Expires: ". gmdate("D, d M Y H:i:s", time() + 60*60*24*7) ." GMT");
This (more or less..) forces your browser to cache the attachment for 7 days. I'm not sure if the Avatars are also cached in some way, but it seems so.

Thanks for the great phpbb3 überboard!

Ambis, phpBB admin for 5 years, Finland

Post Reply

Return to “phpBB Discussion”