I finally managed to set the headers this way :
WebResponse response = (WebResponse) getRequestCycle().getResponse();
response.setDateHeader(Date, System.currentTimeMillis());
response.setDateHeader(Expires, System.currentTimeMillis() +
CACHE_DURATION);
According to http://code.google.com/speed/page-speed/docs/caching.html
you should not set both Expires and Cache-Control: max-age.
I suggest you:
- also set Cache-control: public (see the article).
- get rid of the session cookie when the cvs file is first retrieved.
I think the cookie is the
To set headers to a resource you need to extend setHeaders method from
WebResource. Example:
@Override
protected void setHeaders(WebResponse response)
{
super.setHeaders(response);
response.setAttachmentHeader(announcements.csv);
Thanks for this answer Juri.
I tried it (once again) and it didn't work : the setHeaders method
isn't called...
I use Live HTTP headers to check what goes through :
http://localhost:8080/charts/data/dataId/KBU
GET /charts/data/dataId/KBU HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0
It works for me.
ResourceLink csvLink = new ResourceLink(csvLink, new
ResourceReference(AnnouncementCsvResource.ID), params);
add(csvLink);
public class AnnouncementCsvResource extends WebResource
{
public static final String ID = csv;
@Override
public IResourceStream
hi Juri
I did it the same way as you did and it worked fine. Even more : I
didn't even see lines in http header (???).
However, it doesn't fit my use case : I need to get the link to the
file to embed it in a javascript. Previously I did it this way :
PageParameters parameters = new
hi
We need to provide a flash application (www.amcharts.com if anyone is
interested) with some content through some files.
As the files are users specific (and determined with data from the
session), we went for some page delivering the content like this :
public AMChartDataProviderPage(final