Image Caching
The images for the equipment have to be re-downloaded by the browser on every page load. This takes a lot of time and bandwidth and is not at all optimized - especially for clients connected in remote locations.
The reason for this is that you are not including any cache control hints in the HTTP response headers of the image for the browser to use. Here is a dump of the headers you return with each image:
HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: image/jpeg
Server: Microsoft-IIS/8.5
Content-Disposition: attachment; filename="XXXX"
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 05 Aug 2019 06:05:45 GMT
You need to include one, or more, of the following headers: Expires, Max-Age, E-Tag, Last-Modified to allow a web browser to be smart about not having to ask for the same image again.
Any web server, returning a image file would include one or more of the headers above automatically. You, however, are using a ASP page to fetch the data server-side (from a database or file system) based on the following query string parameters of the FileDownloader.aspx file: ItemID, FileName, and CompanyID. There is nothing wrong with that, but you have to realize that once you use an ASP file to dynamically mimic an image you are also responsible for adding the necessary cache control headers in the response - the server no longer does it automatically.
Here is pseudo-code to add the Last-Modified header to your response:
Response.AddHeader("Last-Modified", HTTPDate(FileCreateDate))
Or, you can send back the Expires header, and set to 2 (or some other number) days in the future:
Response.AddHeader("Expires", HTTPDate(Now + 48 hours))
Either of these are one-line fixes and would drop the bandwidth needed for each page to render by over 50%. This is simple fix well worth your (and all of your clients) time.
Please sign in to leave a comment.
Comments
0 comments