2012-12-29, 10:28 AM
Can we get this bug fixed sometime soon?
It's been there for a while, and the fix isn't that complex.
In attachment.php replace
Not exactly ideal, but is simple and fixes the problem.
Whilst I'm here, might I suggest that cache header handling be improved for attachments?
Currently the attachment script doesn't indicate that the attachment can be cached client side (although it does suppress sending no-cache headers). I haven't tried other browsers, but Firefox does always resend a request because of this, which the reply is always the full attachment.
Indicating the attachment can be cached client side would be helpful for reducing load/bandwidth with thumbnails and users wishing to reopen an attached image, for example. Or at least handle requests with a HTTP 304 response when necessary.
Example MyBB attachment download response headers:
Example XThreads attachment response:
XThreads attachment response to an F5 (normal re-requests are browser cached, so don't trigger a request):
Thanks.
It's been there for a while, and the fix isn't that complex.
In attachment.php replace
echo file_get_contents($mybb->settings['uploadspath']."/".$attachment['attachname']);
with$fp = fopen($mybb->settings['uploadspath']."/".$attachment['attachname'], "rb");
while(!feof($fp)) echo fread($fp, 65536);
fclose($fp);
Not exactly ideal, but is simple and fixes the problem.
Whilst I'm here, might I suggest that cache header handling be improved for attachments?
Currently the attachment script doesn't indicate that the attachment can be cached client side (although it does suppress sending no-cache headers). I haven't tried other browsers, but Firefox does always resend a request because of this, which the reply is always the full attachment.
Indicating the attachment can be cached client side would be helpful for reducing load/bandwidth with thumbnails and users wishing to reopen an attached image, for example. Or at least handle requests with a HTTP 304 response when necessary.
Example MyBB attachment download response headers:
HTTP/1.1 200 OK
Date: Sat, 29 Dec 2012 10:27:18 GMT
Server: Apache/2.4.2 (Win32) PHP/5.4.0
X-Powered-By: PHP/5.4.3
Content-disposition: inline; filename="image.jpg"
Content-Length: 85020
Content-range: bytes=0-85019/85020
Keep-Alive: timeout=3, max=8
Connection: Keep-Alive
Content-Type: image/jpeg
Example XThreads attachment response:
HTTP/1.1 200 OK
Date: Sat, 29 Dec 2012 10:27:52 GMT
Server: Apache/2.4.2 (Win32) PHP/5.4.0
X-Powered-By: PHP/5.4.3
Accept-Ranges: bytes
Allow: GET, HEAD
Last-Modified: Tue, 20 Nov 2012 09:35:29GMT
Expires: Sat, 05 Jan 2013 10:27:52GMT
Cache-Control: max-age=604800
ETag: "xthreads_attach_c1371fff_2_1353404129_7ddc33ff"
Vary: Range
Content-Disposition: inline; filename="image.jpg"
Content-Length: 85020
Content-Range: bytes 0-85019/85020
Content-MD5: fN8FQ4RnEqLWYWtmobS3yA==
Keep-Alive: timeout=3, max=8
Connection: Keep-Alive
Content-Type: image/jpeg
XThreads attachment response to an F5 (normal re-requests are browser cached, so don't trigger a request):
HTTP/1.1 304 Not Modified
Date: Sat, 29 Dec 2012 10:27:59 GMT
Server: Apache/2.4.2 (Win32) PHP/5.4.0
Connection: Keep-Alive
Keep-Alive: timeout=3, max=8
ETag: "xthreads_attach_c1371fff_2_1353404129_7ddc33ff"
Vary: Range
Thanks.