You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dickster <de...@gmail.com> on 2012/10/02 17:46:52 UTC

Re: Appending to CSS url to prevent caching.

i tried using...
getResourceSettings().setCachingStrategy(new
FilenameWithVersionResourceCachingStrategy(new
MessageDigestResourceVersion()));

...but not all of my urls are rewritten.  the wiquery ones are but the one's
i've added via...
 renderHead(response) { 
   response.renderCssReference("blah"); 
}
...don't get appended with version MD5. 
do i have to use different technique for adding them?  (is my current way of
adding them not the preferred way?)








--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652618.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: Appending to CSS url to prevent caching.

Posted by dickster <de...@gmail.com>.
followup just so in case someone else might find this useful. 

the wicket, out of the box css url handling works for resources in the
classpath.  it will not work for stuff you might have tucked away in the
webapp directory which was my case.

for those cases i added a custom header response decorator in the
application.

    protected void validateInit() {
        super.validateInit();        
       setHeaderResponseDecorator( CachingStrategyDecoratingHeaderResponse. 
createHeaderResponseDecorator());
    }

its' responsibility was to append a suffix in the render??Reference methods
that took a URL parameter. 
class CachingStrategyDecoratingHeaderResponse extends
WiQueryDecoratingHeaderResponse {

   public void renderCSSReference(String url) {
        super.renderCSSReference(url+"?VERSION="+someNumber);
    }
    etc....
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4653226.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: Appending to CSS url to prevent caching.

Posted by Jeffrey Schneller <je...@envisa.com>.
You could just add your own cache buster.  You could do something like:

  String cachebuster = "something that will always be unique - maybe time stamp";
  response.renderCSSReference("style/theme.css?" + cachebuster);

not sure if this will bust the cache because the file is really the same.

-or-

  String cachebuster = "something that will always be unique - maybe time stamp";
  response.renderCSSReference("style/theme-" + cachebuster + ".css");

Then you just need a url rewrite rule to change it back to style/theme.css on the server.  I use something similar to this and it works great.



-----Original Message-----
From: dickster [mailto:derek.ipod@gmail.com] 
Sent: Tuesday, October 02, 2012 5:09 PM
To: users@wicket.apache.org
Subject: Re: Appending to CSS url to prevent caching.

sorry, i didn't give a great example.

here's something better.
  response.renderCSSReference("style/theme.css");
it renders the
  <link rel="stylesheet" type="text/css" href="style/theme.css"/> html without the version parameter appended.

maybe i need to do something like...
response.renderCssReference(new CachingReference("style/theme.css"))???


thanks,
derek.





On Tue, Oct 2, 2012 at 4:31 PM, Martin Grigorov-4 [via Apache Wicket] <
ml-node+s1842946n4652625h47@n4.nabble.com> wrote:

> On Tue, Oct 2, 2012 at 6:46 PM, dickster <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4652625&i=0>>
> wrote:
> > i tried using...
> > getResourceSettings().setCachingStrategy(new
> > FilenameWithVersionResourceCachingStrategy(new
> > MessageDigestResourceVersion()));
> >
> > ...but not all of my urls are rewritten.  the wiquery ones are but 
> > the
> one's
> > i've added via...
> >  renderHead(response) {
> >    response.renderCssReference("blah");
>
> What kind of CSS this produces ?
> I think this generates:
> <style>
> blah
> </style>
> directly in the page markup. If I'm correct then there is no need to 
> add anti-caching here because next render of the page will deliver 
> whatever is needed.
> Only external file resources can be cached.
>
> > }
> > ...don't get appended with version MD5.
> > do i have to use different technique for adding them?  (is my 
> > current
> way of
> > adding them not the preferred way?)
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-pre
> vent-caching-tp4652508p4652618.html
>
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=4652625&i=1>
> > For additional commands, e-mail: [hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=4652625&i=2>
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4652625&i=3>
> For additional commands, e-mail: [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4652625&i=4>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the 
> discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-pre
> vent-caching-tp4652508p4652625.html
>  To unsubscribe from Appending to CSS url to prevent caching., click 
> here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.j
> tp?macro=unsubscribe_by_code&node=4652508&code=ZGVyZWsuaXBvZEBnbWFpbC5
> jb218NDY1MjUwOHwtMjM5OTAwMTA0>
> .
> NAML<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.j
> tp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabbl
> e.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamesp
> ace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscrib
> ers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_in
> stant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652626.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


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


Re: Appending to CSS url to prevent caching.

Posted by dickster <de...@gmail.com>.
sorry, i didn't give a great example.

here's something better.
  response.renderCSSReference("style/theme.css");
it renders the
  <link rel="stylesheet" type="text/css" href="style/theme.css"/>
html without the version parameter appended.

maybe i need to do something like...
response.renderCssReference(new CachingReference("style/theme.css"))???


thanks,
derek.





On Tue, Oct 2, 2012 at 4:31 PM, Martin Grigorov-4 [via Apache Wicket] <
ml-node+s1842946n4652625h47@n4.nabble.com> wrote:

> On Tue, Oct 2, 2012 at 6:46 PM, dickster <[hidden email]<http://user/SendEmail.jtp?type=node&node=4652625&i=0>>
> wrote:
> > i tried using...
> > getResourceSettings().setCachingStrategy(new
> > FilenameWithVersionResourceCachingStrategy(new
> > MessageDigestResourceVersion()));
> >
> > ...but not all of my urls are rewritten.  the wiquery ones are but the
> one's
> > i've added via...
> >  renderHead(response) {
> >    response.renderCssReference("blah");
>
> What kind of CSS this produces ?
> I think this generates:
> <style>
> blah
> </style>
> directly in the page markup. If I'm correct then there is no need to
> add anti-caching here because next render of the page will deliver
> whatever is needed.
> Only external file resources can be cached.
>
> > }
> > ...don't get appended with version MD5.
> > do i have to use different technique for adding them?  (is my current
> way of
> > adding them not the preferred way?)
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652618.html
>
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4652625&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4652625&i=2>
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4652625&i=3>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=4652625&i=4>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652625.html
>  To unsubscribe from Appending to CSS url to prevent caching., click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4652508&code=ZGVyZWsuaXBvZEBnbWFpbC5jb218NDY1MjUwOHwtMjM5OTAwMTA0>
> .
> NAML<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652626.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: Appending to CSS url to prevent caching.

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Oct 2, 2012 at 6:46 PM, dickster <de...@gmail.com> wrote:
> i tried using...
> getResourceSettings().setCachingStrategy(new
> FilenameWithVersionResourceCachingStrategy(new
> MessageDigestResourceVersion()));
>
> ...but not all of my urls are rewritten.  the wiquery ones are but the one's
> i've added via...
>  renderHead(response) {
>    response.renderCssReference("blah");

What kind of CSS this produces ?
I think this generates:
<style>
blah
</style>
directly in the page markup. If I'm correct then there is no need to
add anti-caching here because next render of the page will deliver
whatever is needed.
Only external file resources can be cached.

> }
> ...don't get appended with version MD5.
> do i have to use different technique for adding them?  (is my current way of
> adding them not the preferred way?)
>
>
>
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Appending-to-CSS-url-to-prevent-caching-tp4652508p4652618.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
>



-- 
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