0

Greeting fellows! I have been using HTML5 application cache to create an offline web app recently. Everything works great on Chrome until I am implementing the "offline attachment download" function. Basically I have cached a servlet into the application cache. This servlet is actually a .jpg attachment with the following header:

HTTP/1.1 200 OK
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Content-Type: application/octet-stream
Date: Fri, 11 Jan 2013 09:01:23 GMT
Content-Disposition: attachment; filename=MailAttachment.jpg
DownloadFileName: Snap1.jpg
Server: nginx/1.0.10
Cache-Control: private
Pragma: cache
Content-Length: 220005

What I try to achieve is when I visit this servlet offline, the image named "MailAttachment.jpg" will be downloaded (acutally from application cache) to browser-specified diretory. However, the thing is when I visited this servlet without network connection, the browser attempted to download "MailAttachment.jpg" but cancelled it immediately. When the content length is small enough (e.g. 1kb), the browser successfully downloaded the attachment. I suspect there are some improper headers in the cached servlet. Anybody has idea of the solution? Thanks very much in advance!

  • I suspect that the small image is cached by the browser, not the application cache. Did you forget to list the image in the manifest? – blurrcat Jan 15 '13 at 02:22
  • in my manifest, I cached the servlet not the image itself. The response of this servlet contains the headers shown above and the response body is bytes of that target images. @blurrcat – Nemo Bryant Jan 15 '13 at 06:02
  • Sorry I don't know what do you mean by "cache a servlet". If the servlet can be seen as a resource identified by a url, then you need to put the url in either the cache section or the network section in your manifest. – blurrcat Jan 15 '13 at 06:31
  • Exactly. In the manifest file, the CACHE: section includes the servlet url. This is the meaning of "cache a servlet". When I visited the servlet, the browser actually fetch it from application cache (I can see it from Chrome developer tool). Because of the response headers, the browser will try to download an attachment. At this point, it cancelled immediately. @blurrcat – Nemo Bryant Jan 15 '13 at 07:16

0 Answers0