You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by hok <iv...@gmail.com> on 2011/03/24 00:02:02 UTC

PackageResourceReference, MetaInfStaticResourceReference and timestamps

Hello, 
I have two questions:
1. Currently it's possible to have: 

	@Override
	public void renderHead(final IHeaderResponse response) {
		super.renderHead(response);

		response.renderCSSReference(new PackageResourceReference(getClass(),
getClass().getSimpleName() + ".css"));
		response.renderCSSReference("css/root.css");
	}

Using a PackageResourceReference has the advantage of adding a last modified
timestamp to the filename (if enabled). Is it possible to have the same
thing for root.css, which resides in the root of the webapp ?

2. In the Servlet 3.0 specification it's possible to have static resources
under META-INF/resources and I noticed that wicket has
MetaInfStaticResourceReference, which is better for serving static
resources. In my case for some components I have css files which are loaded
like: 

	response.renderCSSReference(new PackageResourceReference(getClass(),
getClass().getSimpleName() + ".css"));

So, it should be better to move all those css files under
META-INF/resources. However, this somehow contradicts with the wicket
philosophy of having everything in one place and requires maintaining a 
parallel package folder structure under META-INF/resources. Do you think
it's worth it?

Thanks.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/PackageResourceReference-MetaInfStaticResourceReference-and-timestamps-tp3401055p3401055.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Mar 24, 2011 at 2:19 PM, Peter Ertl <pe...@gmx.org> wrote:

> looks like a refactoring-nightmare ...
>
> Can you be more specific ?

I even see it easier to manage.
With wro.xml you have all resources specified in one place but in different
groupd.
With default Wicket approach you have a ResRef in every .java file that
needs them.
By refactoring I guess you mean renaming the .java class name or even moving
the class in different package. The IDE wont help you
here - it wont move the .css together with the .java, so you'll need to
either touch the path in the ResRef or move the resource after the
refactoring.

Or I didn't understand you ?


> Am 24.03.2011 um 12:23 schrieb Martin Grigorov:
>
> > On Thu, Mar 24, 2011 at 12:13 PM, Martijn Dashorst <
> > martijn.dashorst@gmail.com> wrote:
> >
> >> On Thu, Mar 24, 2011 at 12:02 PM, James Carman
> >> <ja...@carmanconsulting.com> wrote:
> >>> Yes, but you would have to change how you refer to them, right?
> >>
> >> Not sure how that would work out, haven't tried it. Isn't this also a
> >> tomcat specific optimization as well?
> >>
> > It is by Servlet 3.0 specification.
> >
> > My recent research shows that Wicket+Wro4j is the best approach.
> >
> > wro.xml:
> > <group name="style">
> >        <css>/css/context.css</css>
> >        <css>classpath:/com/mycompany/components/Component1.css</css>
> >        <css>classpath:/com/mycompany/components/Component2.css</css>
> >        <css>classpath:/com/mycompany/components/Component3.css</css>
> > </group>
> >
> > Don't use ResourceReference but just put
> > <link rel="stylesheet" href="wro/style.css"/>
> >
> > in the page that uses these components.
> >
> >
> >
> >
> >> Martijn
> >>
> >> ---------------------------------------------------------------------
> >> 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 <http://jweekend.com/>
>
>
> ---------------------------------------------------------------------
> 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 <http://jweekend.com/>

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Peter Ertl <pe...@gmx.org>.
looks like a refactoring-nightmare ...

Am 24.03.2011 um 12:23 schrieb Martin Grigorov:

> On Thu, Mar 24, 2011 at 12:13 PM, Martijn Dashorst <
> martijn.dashorst@gmail.com> wrote:
> 
>> On Thu, Mar 24, 2011 at 12:02 PM, James Carman
>> <ja...@carmanconsulting.com> wrote:
>>> Yes, but you would have to change how you refer to them, right?
>> 
>> Not sure how that would work out, haven't tried it. Isn't this also a
>> tomcat specific optimization as well?
>> 
> It is by Servlet 3.0 specification.
> 
> My recent research shows that Wicket+Wro4j is the best approach.
> 
> wro.xml:
> <group name="style">
>        <css>/css/context.css</css>
>        <css>classpath:/com/mycompany/components/Component1.css</css>
>        <css>classpath:/com/mycompany/components/Component2.css</css>
>        <css>classpath:/com/mycompany/components/Component3.css</css>
> </group>
> 
> Don't use ResourceReference but just put
> <link rel="stylesheet" href="wro/style.css"/>
> 
> in the page that uses these components.
> 
> 
> 
> 
>> Martijn
>> 
>> ---------------------------------------------------------------------
>> 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 <http://jweekend.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Mar 24, 2011 at 12:13 PM, Martijn Dashorst <
martijn.dashorst@gmail.com> wrote:

> On Thu, Mar 24, 2011 at 12:02 PM, James Carman
> <ja...@carmanconsulting.com> wrote:
> > Yes, but you would have to change how you refer to them, right?
>
> Not sure how that would work out, haven't tried it. Isn't this also a
> tomcat specific optimization as well?
>
It is by Servlet 3.0 specification.

My recent research shows that Wicket+Wro4j is the best approach.

wro.xml:
 <group name="style">
        <css>/css/context.css</css>
        <css>classpath:/com/mycompany/components/Component1.css</css>
        <css>classpath:/com/mycompany/components/Component2.css</css>
        <css>classpath:/com/mycompany/components/Component3.css</css>
 </group>

Don't use ResourceReference but just put
<link rel="stylesheet" href="wro/style.css"/>

in the page that uses these components.




> Martijn
>
> ---------------------------------------------------------------------
> 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 <http://jweekend.com/>

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Martijn Dashorst <ma...@gmail.com>.
On Thu, Mar 24, 2011 at 12:02 PM, James Carman
<ja...@carmanconsulting.com> wrote:
> Yes, but you would have to change how you refer to them, right?

Not sure how that would work out, haven't tried it. Isn't this also a
tomcat specific optimization as well?

Martijn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by James Carman <ja...@carmanconsulting.com>.
Yes, but you would have to change how you refer to them, right?

On Thu, Mar 24, 2011 at 6:33 AM, Martijn Dashorst
<ma...@gmail.com> wrote:
> For development you can keep the resources in the usual, wicket
> preferred location (next to the class files), and when you package
> your jars you can instruct your build tool to move them to
> META-INF/resources
>
> Best of both worlds :)
>
> Martijn
>
> On Thu, Mar 24, 2011 at 7:17 AM, Attila Király
> <ki...@gmail.com> wrote:
>> 2011/3/24 hok <iv...@gmail.com>
>>>
>>> 2. In the Servlet 3.0 specification it's possible to have static resources
>>> under META-INF/resources and I noticed that wicket has
>>> MetaInfStaticResourceReference, which is better for serving static
>>> resources. In my case for some components I have css files which are loaded
>>> like:
>>>
>>>        response.renderCSSReference(new PackageResourceReference(getClass(),
>>> getClass().getSimpleName() + ".css"));
>>>
>>> So, it should be better to move all those css files under
>>> META-INF/resources. However, this somehow contradicts with the wicket
>>> philosophy of having everything in one place and requires maintaining a
>>> parallel package folder structure under META-INF/resources. Do you think
>>> it's worth it?
>>>
>>
>> Hi,
>>
>> In my tests I found that Tomcat 7 serves static files from
>> META-INF/resources directory 2-3 times faster than wicket. So if performance
>> is important I think it is worth it. I am pragmatic about it: maybe it is
>> bad to not hold everything in the same directory but this is a feature that
>> fits wicket pretty well (bundling static files in jars) so it would be worse
>> to not use it.
>>
>> Attila
>>
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Martijn Dashorst <ma...@gmail.com>.
For development you can keep the resources in the usual, wicket
preferred location (next to the class files), and when you package
your jars you can instruct your build tool to move them to
META-INF/resources

Best of both worlds :)

Martijn

On Thu, Mar 24, 2011 at 7:17 AM, Attila Király
<ki...@gmail.com> wrote:
> 2011/3/24 hok <iv...@gmail.com>
>>
>> 2. In the Servlet 3.0 specification it's possible to have static resources
>> under META-INF/resources and I noticed that wicket has
>> MetaInfStaticResourceReference, which is better for serving static
>> resources. In my case for some components I have css files which are loaded
>> like:
>>
>>        response.renderCSSReference(new PackageResourceReference(getClass(),
>> getClass().getSimpleName() + ".css"));
>>
>> So, it should be better to move all those css files under
>> META-INF/resources. However, this somehow contradicts with the wicket
>> philosophy of having everything in one place and requires maintaining a
>> parallel package folder structure under META-INF/resources. Do you think
>> it's worth it?
>>
>
> Hi,
>
> In my tests I found that Tomcat 7 serves static files from
> META-INF/resources directory 2-3 times faster than wicket. So if performance
> is important I think it is worth it. I am pragmatic about it: maybe it is
> bad to not hold everything in the same directory but this is a feature that
> fits wicket pretty well (bundling static files in jars) so it would be worse
> to not use it.
>
> Attila
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Attila Király <ki...@gmail.com>.
2011/3/25 <MZ...@osc.state.ny.us>

> <Hi,
> <
> <I made a new test (serving a png and a js) with current trunk and the gap
> is
> <much smaller now: tomcat is 25% faster on average.
> <
> <Attila
>
> Attila can you elaborate on your tests?  Are you comparing the difference
> between using a resource reference (js) and image component (png) in
> wicket vs linking straight the to the files in html?  If so, what
> relevance does whether the static files are in META-INF or WEB-INF have?
> Not that much because if I am correct the extra overhead is introduced by
> having wicket process the resource and spit out the markup...
>
>
Hi!

In speed test I compared the serving time of the static resources directly
(and not the rendering time of the url-s in the wicket page or the page
itself). With jmeter I calculated the average time for serving 20k times the
same resource trough Servlet 3.0 meta and trough wicket.

Attila

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by MZ...@osc.state.ny.us.
<Hi,
<
<I made a new test (serving a png and a js) with current trunk and the gap 
is
<much smaller now: tomcat is 25% faster on average.
<
<Attila

Attila can you elaborate on your tests?  Are you comparing the difference 
between using a resource reference (js) and image component (png) in 
wicket vs linking straight the to the files in html?  If so, what 
relevance does whether the static files are in META-INF or WEB-INF have? 
Not that much because if I am correct the extra overhead is introduced by 
having wicket process the resource and spit out the markup...



Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Attila Király <ki...@gmail.com>.
2011/3/24 Martin Grigorov <mg...@apache.org>

> Hi,
>
> On Thu, Mar 24, 2011 at 7:17 AM, Attila Király <kiralyattila.hu@gmail.com
> >wrote:
>
> > 2011/3/24 hok <iv...@gmail.com>
> > >
> > > 2. In the Servlet 3.0 specification it's possible to have static
> > resources
> > > under META-INF/resources and I noticed that wicket has
> > > MetaInfStaticResourceReference, which is better for serving static
> > > resources. In my case for some components I have css files which are
> > loaded
> > > like:
> > >
> > >        response.renderCSSReference(new
> > PackageResourceReference(getClass(),
> > > getClass().getSimpleName() + ".css"));
> > >
> > > So, it should be better to move all those css files under
> > > META-INF/resources. However, this somehow contradicts with the wicket
> > > philosophy of having everything in one place and requires maintaining a
> > > parallel package folder structure under META-INF/resources. Do you
> think
> > > it's worth it?
> > >
> >
> > Hi,
> >
> > In my tests I found that Tomcat 7 serves static files from
> > META-INF/resources directory 2-3 times faster than wicket. So if
> > performance
> > is important I think it is worth it. I am pragmatic about it: maybe it is
> > bad to not hold everything in the same directory but this is a feature
> that
> > fits wicket pretty well (bundling static files in jars) so it would be
> > worse
> > to not use it.
> >
> > Attila
> >
> With the new CachingResourceStreamLocator the serving should be faster now.
> See https://issues.apache.org/jira/browse/WICKET-3511.
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>

Hi,

I made a new test (serving a png and a js) with current trunk and the gap is
much smaller now: tomcat is 25% faster on average.

Attila

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Peter Ertl <pe...@gmx.org>.
You can attach a front-end proxy like nginx or apache that caches resources delivered by your wicket application so subsequent requests will be served from the proxy cache with maximum speed.


Am 24.03.2011 um 09:01 schrieb Martin Grigorov:

> Hi,
> 
> On Thu, Mar 24, 2011 at 7:17 AM, Attila Király <ki...@gmail.com>wrote:
> 
>> 2011/3/24 hok <iv...@gmail.com>
>>> 
>>> 2. In the Servlet 3.0 specification it's possible to have static
>> resources
>>> under META-INF/resources and I noticed that wicket has
>>> MetaInfStaticResourceReference, which is better for serving static
>>> resources. In my case for some components I have css files which are
>> loaded
>>> like:
>>> 
>>>       response.renderCSSReference(new
>> PackageResourceReference(getClass(),
>>> getClass().getSimpleName() + ".css"));
>>> 
>>> So, it should be better to move all those css files under
>>> META-INF/resources. However, this somehow contradicts with the wicket
>>> philosophy of having everything in one place and requires maintaining a
>>> parallel package folder structure under META-INF/resources. Do you think
>>> it's worth it?
>>> 
>> 
>> Hi,
>> 
>> In my tests I found that Tomcat 7 serves static files from
>> META-INF/resources directory 2-3 times faster than wicket. So if
>> performance
>> is important I think it is worth it. I am pragmatic about it: maybe it is
>> bad to not hold everything in the same directory but this is a feature that
>> fits wicket pretty well (bundling static files in jars) so it would be
>> worse
>> to not use it.
>> 
>> Attila
>> 
> With the new CachingResourceStreamLocator the serving should be faster now.
> See https://issues.apache.org/jira/browse/WICKET-3511.
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Thu, Mar 24, 2011 at 7:17 AM, Attila Király <ki...@gmail.com>wrote:

> 2011/3/24 hok <iv...@gmail.com>
> >
> > 2. In the Servlet 3.0 specification it's possible to have static
> resources
> > under META-INF/resources and I noticed that wicket has
> > MetaInfStaticResourceReference, which is better for serving static
> > resources. In my case for some components I have css files which are
> loaded
> > like:
> >
> >        response.renderCSSReference(new
> PackageResourceReference(getClass(),
> > getClass().getSimpleName() + ".css"));
> >
> > So, it should be better to move all those css files under
> > META-INF/resources. However, this somehow contradicts with the wicket
> > philosophy of having everything in one place and requires maintaining a
> > parallel package folder structure under META-INF/resources. Do you think
> > it's worth it?
> >
>
> Hi,
>
> In my tests I found that Tomcat 7 serves static files from
> META-INF/resources directory 2-3 times faster than wicket. So if
> performance
> is important I think it is worth it. I am pragmatic about it: maybe it is
> bad to not hold everything in the same directory but this is a feature that
> fits wicket pretty well (bundling static files in jars) so it would be
> worse
> to not use it.
>
> Attila
>
With the new CachingResourceStreamLocator the serving should be faster now.
See https://issues.apache.org/jira/browse/WICKET-3511.


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: PackageResourceReference, MetaInfStaticResourceReference and timestamps

Posted by Attila Király <ki...@gmail.com>.
2011/3/24 hok <iv...@gmail.com>
>
> 2. In the Servlet 3.0 specification it's possible to have static resources
> under META-INF/resources and I noticed that wicket has
> MetaInfStaticResourceReference, which is better for serving static
> resources. In my case for some components I have css files which are loaded
> like:
>
>        response.renderCSSReference(new PackageResourceReference(getClass(),
> getClass().getSimpleName() + ".css"));
>
> So, it should be better to move all those css files under
> META-INF/resources. However, this somehow contradicts with the wicket
> philosophy of having everything in one place and requires maintaining a
> parallel package folder structure under META-INF/resources. Do you think
> it's worth it?
>

Hi,

In my tests I found that Tomcat 7 serves static files from
META-INF/resources directory 2-3 times faster than wicket. So if performance
is important I think it is worth it. I am pragmatic about it: maybe it is
bad to not hold everything in the same directory but this is a feature that
fits wicket pretty well (bundling static files in jars) so it would be worse
to not use it.

Attila