0
votes

On a XPage, when I want to display an image which is stored as a file attachment of a NotesDocument, I define the image source as follows: [UNID_OF_FILE]/$FILE/[NAME_OF_ATTACHMENT].

Whenever a page contains this kind of source, a HTTP request is performed. Since there is no "Expires" date defined in the response headers, the HTTP status is (in best case) "304 Not Modified", which means that the attachment is not again loaded from the server. However, this is still a HTTP request that increases the page's loading time. Is there a way to set the expiration date for these responses to get a HTTP status "200 OK (Cache)" which does not perform a HTTP request and directly loads the image ressource from the cache?

PS: I know I could create a "helper" XPage (for downloading this file attachment) which manually sets the response headers with facesContext.getExternalContext().getResponse().setHeader(...) etc. Yet this would mean that I would have to largely rewrite my XPages application. I hope that there are some server or database settings that allow to directly set the corresponding response headers.

1
The URL you are using for the attachment isn't the XPages syntax, but the classic web URL. So there's nothing you can do "the XPages way" unless you change that. How many points do you have where you expose the attachment urls? That are the only ones you need to changestwissel
@stwissel: If I would use the native XPages syntax for attachment URLs, which you describe in your article "Attachment URLs in XPages", would it then be possible to set the expiration date for the cache? Maybe as an URL parameter?xpages-noob
I don't think so. Xpages doesn't support JEE filters, so you really end up with an auxiliary XPage or (better?) a custom resource provider with the required behaviorstwissel
@stwissel: Thanks for the information. Since I have no experience in developing custom resource providers, I'll stick to writing an auxiliary XPage.xpages-noob
Perhaps you can add an Internet web site rule that sets the headers?Per Henrik Lausten

1 Answers

3
votes

You can add a Web Site Rule that sets the Expires header (and other HTTP headers).

Here's an example of a web site rule that sets the Expires header to 14 days for all files of type jpg:

enter image description here