Patch #37600
openCache attachments and thumbnails in web browsers
0%
Description
The attached patch adds "max-age" value to "Cache-Control" filed in response headers of AttachmentController#download
and AttachmentController#thumbnail
in order to reduce the number of requests to a Redmine server and speed up page loading especially when an issue or a Wiki page has dozens of inline images and thumbnails.
Before:
Cache-Control: private
After:
Cache-Control: max-age=86400, private
In my observation, some users attach about 100 or more images to an issue. Even if they access the issue again shortly after it was accessed, their browser sends many GET requests to AttachmentController#download
and AttachmentController#thumbnail
to revalidate their local cache. Each of those requests that receive "304 Not Modified" consumes a few tens of milliseconds of server time.
By adding "max-age: 86400" to "Cache-Control" header field, web browsers will cache images and thumbnails and will not make revalidate requests for 24 hours, which improves page loading speed and reduces server load.
In Redmine, the content of attachments and thumbnails with the same URL is immutable. So there is no need to frequently revalidate the local cache and it is safe to keep the cache for some time.
It is safe to keep caches of attachments and thumbnails for some time because the content of attachments and thumbnails with the same URL is immutable in Redmine. And there is no need to frequently revalidate the local cache.
Files