You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Peter Karich <pe...@yahoo.de> on 2011/07/10 18:08:38 UTC
YSlow still complaining "Add Expires headers"
Hi all,
because of the advice in
http://apache-wicket.1842946.n4.nabble.com/expires-header-td1866672.html
https://issues.apache.org/jira/browse/WICKET-1602
I used getResourceSettings().setDefaultCacheDuration(30 * 24 * 3600);
in my WebApplication. I also did some other hacking [1] to set the
Expires header.
But I still see "Add Expires headers" in YSlow [2] and Page Speed [3].
What is the correct way to set the "Expires" headers?
Regards,
Peter.
[1]
@Override
protected void configureResponse() {
super.configureResponse();
// Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM
yyyy HH:mm:ss z");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
WebResponse response = getWebRequestCycle().getWebResponse();
int minutes = 30 * 24 * 60;
response.setHeader("Cache-Control", "public, max-age=" + minutes
* 60);
String str = formatter.format(new
MyDate().plusMinutes(minutes).toDate());
response.setHeader("Expires", str);
str = formatter.format(new MyDate().minusMinutes(minutes).toDate());
response.setHeader("Last-Modified", str);
// response.setHeader("Pragma", "no-cache");
// response.setHeader("Keep-Alive", "" + minutes * 60);
}
[2]
There are 29 static components without a far-future expiration date.
[3]
http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageBrowserCaching
--
http://jetsli.de Hackernews+
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: YSlow still complaining "Add Expires headers"
Posted by Peter Karich <pe...@yahoo.de>.
Am 11.07.2011 14:44, schrieb Martin Grigorov:
> See what happens in
> org.apache.wicket.markup.html.WebResource.setHeaders(WebResponse).
> Then check the response headers for your resources.
>
> I guess that your resources are located next to WEB-INF folder and are
> delivered directly by the web container and thus Wicket doesn't set
> the headers.
> If this is the case then you here are two options:
> - check your web container documentation
> - add a filter in web.xml that will set the headers for all requests
> to /css/*.css, /js/*.js, ...
Thanks Martin, that helped! I wrote a filter:
@Override public void doFilter(ServletRequest request, ServletResponse
response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse rsp = (HttpServletResponse) response;
SimpleDateFormat formatter = new
SimpleDateFormat(Helper.cacheDateFormatString);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
int minutes = 30 * 24 * 60;
rsp.setHeader("Cache-Control", "public, max-age=" + minutes * 60);
chain.doFilter(request, response);
}
Also this helped with all the confusing options in the header:
http://onjava.com/pub/a/onjava/2004/03/03/filters.html?page=2
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: YSlow still complaining "Add Expires headers"
Posted by Martin Grigorov <mg...@apache.org>.
See what happens in
org.apache.wicket.markup.html.WebResource.setHeaders(WebResponse).
Then check the response headers for your resources.
I guess that your resources are located next to WEB-INF folder and are
delivered directly by the web container and thus Wicket doesn't set
the headers.
If this is the case then you here are two options:
- check your web container documentation
- add a filter in web.xml that will set the headers for all requests
to /css/*.css, /js/*.js, ...
On Mon, Jul 11, 2011 at 2:29 PM, Peter Karich <pe...@yahoo.de> wrote:
> anyone an idea how to change cache duration of resources?
> (as setDefaultCacheDuration doesn't work for me)
>
>> Martin,
>>
>> I'm using 1.4.17
>>
>>> Your [1] is about the page itself, not about the resources
>>> (.css, .js, images, ...).
>> ok. I just wasn't sure.
>>
>> Regards,
>> Peter.
>>
>>> Which version of Wicket ?
>>> Your [1] is about the page itself, not about the resources (.css, .js,
>>> images, ...).
>>>
>>> On Sun, Jul 10, 2011 at 6:08 PM, Peter Karich <pe...@yahoo.de> wrote:
>>>> Hi all,
>>>>
>>>> because of the advice in
>>>>
>>>> http://apache-wicket.1842946.n4.nabble.com/expires-header-td1866672.html
>>>> https://issues.apache.org/jira/browse/WICKET-1602
>>>>
>>>> I used getResourceSettings().setDefaultCacheDuration(30 * 24 * 3600);
>>>> in my WebApplication. I also did some other hacking [1] to set the
>>>> Expires header.
>>>> But I still see "Add Expires headers" in YSlow [2] and Page Speed [3].
>>>>
>>>> What is the correct way to set the "Expires" headers?
>>>>
>>>> Regards,
>>>> Peter.
>>>>
>>>> [1]
>>>> @Override
>>>> protected void configureResponse() {
>>>> super.configureResponse();
>>>> // Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
>>>> SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM
>>>> yyyy HH:mm:ss z");
>>>> formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
>>>>
>>>> WebResponse response = getWebRequestCycle().getWebResponse();
>>>> int minutes = 30 * 24 * 60;
>>>> response.setHeader("Cache-Control", "public, max-age=" + minutes
>>>> * 60);
>>>> String str = formatter.format(new
>>>> MyDate().plusMinutes(minutes).toDate());
>>>> response.setHeader("Expires", str);
>>>>
>>>> str = formatter.format(new MyDate().minusMinutes(minutes).toDate());
>>>> response.setHeader("Last-Modified", str);
>>>>
>>>> // response.setHeader("Pragma", "no-cache");
>>>> // response.setHeader("Keep-Alive", "" + minutes * 60);
>>>> }
>>>>
>>>> [2]
>>>> There are 29 static components without a far-future expiration date.
>>>>
>>>> [3]
>>>> http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageBrowserCaching
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: YSlow still complaining "Add Expires headers"
Posted by Peter Karich <pe...@yahoo.de>.
anyone an idea how to change cache duration of resources?
(as setDefaultCacheDuration doesn't work for me)
> Martin,
>
> I'm using 1.4.17
>
>> Your [1] is about the page itself, not about the resources
>> (.css, .js, images, ...).
> ok. I just wasn't sure.
>
> Regards,
> Peter.
>
>> Which version of Wicket ?
>> Your [1] is about the page itself, not about the resources (.css, .js,
>> images, ...).
>>
>> On Sun, Jul 10, 2011 at 6:08 PM, Peter Karich <pe...@yahoo.de> wrote:
>>> Hi all,
>>>
>>> because of the advice in
>>>
>>> http://apache-wicket.1842946.n4.nabble.com/expires-header-td1866672.html
>>> https://issues.apache.org/jira/browse/WICKET-1602
>>>
>>> I used getResourceSettings().setDefaultCacheDuration(30 * 24 * 3600);
>>> in my WebApplication. I also did some other hacking [1] to set the
>>> Expires header.
>>> But I still see "Add Expires headers" in YSlow [2] and Page Speed [3].
>>>
>>> What is the correct way to set the "Expires" headers?
>>>
>>> Regards,
>>> Peter.
>>>
>>> [1]
>>> @Override
>>> protected void configureResponse() {
>>> super.configureResponse();
>>> // Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
>>> SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM
>>> yyyy HH:mm:ss z");
>>> formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
>>>
>>> WebResponse response = getWebRequestCycle().getWebResponse();
>>> int minutes = 30 * 24 * 60;
>>> response.setHeader("Cache-Control", "public, max-age=" + minutes
>>> * 60);
>>> String str = formatter.format(new
>>> MyDate().plusMinutes(minutes).toDate());
>>> response.setHeader("Expires", str);
>>>
>>> str = formatter.format(new MyDate().minusMinutes(minutes).toDate());
>>> response.setHeader("Last-Modified", str);
>>>
>>> // response.setHeader("Pragma", "no-cache");
>>> // response.setHeader("Keep-Alive", "" + minutes * 60);
>>> }
>>>
>>> [2]
>>> There are 29 static components without a far-future expiration date.
>>>
>>> [3]
>>> http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageBrowserCaching
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: YSlow still complaining "Add Expires headers"
Posted by Peter Karich <pe...@yahoo.de>.
Martin,
I'm using 1.4.17
> Your [1] is about the page itself, not about the resources
> (.css, .js, images, ...).
ok. I just wasn't sure.
Regards,
Peter.
> Which version of Wicket ?
> Your [1] is about the page itself, not about the resources (.css, .js,
> images, ...).
>
> On Sun, Jul 10, 2011 at 6:08 PM, Peter Karich <pe...@yahoo.de> wrote:
>> Hi all,
>>
>> because of the advice in
>>
>> http://apache-wicket.1842946.n4.nabble.com/expires-header-td1866672.html
>> https://issues.apache.org/jira/browse/WICKET-1602
>>
>> I used getResourceSettings().setDefaultCacheDuration(30 * 24 * 3600);
>> in my WebApplication. I also did some other hacking [1] to set the
>> Expires header.
>> But I still see "Add Expires headers" in YSlow [2] and Page Speed [3].
>>
>> What is the correct way to set the "Expires" headers?
>>
>> Regards,
>> Peter.
>>
>> [1]
>> @Override
>> protected void configureResponse() {
>> super.configureResponse();
>> // Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
>> SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM
>> yyyy HH:mm:ss z");
>> formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
>>
>> WebResponse response = getWebRequestCycle().getWebResponse();
>> int minutes = 30 * 24 * 60;
>> response.setHeader("Cache-Control", "public, max-age=" + minutes
>> * 60);
>> String str = formatter.format(new
>> MyDate().plusMinutes(minutes).toDate());
>> response.setHeader("Expires", str);
>>
>> str = formatter.format(new MyDate().minusMinutes(minutes).toDate());
>> response.setHeader("Last-Modified", str);
>>
>> // response.setHeader("Pragma", "no-cache");
>> // response.setHeader("Keep-Alive", "" + minutes * 60);
>> }
>>
>> [2]
>> There are 29 static components without a far-future expiration date.
>>
>> [3]
>> http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageBrowserCaching
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: YSlow still complaining "Add Expires headers"
Posted by Martin Grigorov <mg...@apache.org>.
Which version of Wicket ?
Your [1] is about the page itself, not about the resources (.css, .js,
images, ...).
On Sun, Jul 10, 2011 at 6:08 PM, Peter Karich <pe...@yahoo.de> wrote:
> Hi all,
>
> because of the advice in
>
> http://apache-wicket.1842946.n4.nabble.com/expires-header-td1866672.html
> https://issues.apache.org/jira/browse/WICKET-1602
>
> I used getResourceSettings().setDefaultCacheDuration(30 * 24 * 3600);
> in my WebApplication. I also did some other hacking [1] to set the
> Expires header.
> But I still see "Add Expires headers" in YSlow [2] and Page Speed [3].
>
> What is the correct way to set the "Expires" headers?
>
> Regards,
> Peter.
>
> [1]
> @Override
> protected void configureResponse() {
> super.configureResponse();
> // Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
> SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM
> yyyy HH:mm:ss z");
> formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
>
> WebResponse response = getWebRequestCycle().getWebResponse();
> int minutes = 30 * 24 * 60;
> response.setHeader("Cache-Control", "public, max-age=" + minutes
> * 60);
> String str = formatter.format(new
> MyDate().plusMinutes(minutes).toDate());
> response.setHeader("Expires", str);
>
> str = formatter.format(new MyDate().minusMinutes(minutes).toDate());
> response.setHeader("Last-Modified", str);
>
> // response.setHeader("Pragma", "no-cache");
> // response.setHeader("Keep-Alive", "" + minutes * 60);
> }
>
> [2]
> There are 29 static components without a far-future expiration date.
>
> [3]
> http://code.google.com/intl/de-DE/speed/page-speed/docs/caching.html#LeverageBrowserCaching
>
> --
> http://jetsli.de Hackernews+
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org