You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matt Smith <ma...@gmail.com> on 2008/01/16 17:18:08 UTC

Javascript/CSS being cached by the browser even when it has changed. Should setAddLastModifiedTimeToResourceReferenceUrl(true) be the default?

Hello I've been using wicket for almost a year.  I recently ran into the
common web problem of the browser being overly aggressive on caching
javascript files.   This is commonly solved by adding a query parm which
changes based on the contents of the js file (checksum, time-stamp, etc).

After some searching (through forums, documentation, and wiki), I found the
following mailing list thread which alluded to the feature being done:
http://www.nabble.com/Wicket-2%2C-modal-window%2C-ListChoice%2C-auto-completion-to6352037.html#a6386238

It took some debugging through the wicket source, but I found the following
setting which can be flipped to enable this behavior (adding a lastmodified
url parm):

getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);

The reason I'm posting this message is so that anyone else encountering a
similar problem might have a better search result that shows the solution.
Since I've been using wicket for some time, maybe I should have known to
look in all the settings interfaces?  However this doesn't seem like
something you would want to turn off.

Could you (wicket-committers) consider changing this to the default behavior
since browsers have a common problem of caching those files too
aggressively?   Using the lastmodifiedTime is a good approach to forcing the
browser to refresh only when appropriate.   I think it's much better than
the current default of allowing for the browser to behave strangely when the
resource has changed on the server and requiring the user to manually clear
their browser cache.

Thanks,
   Matt - http://netsmith.blogspot.com

Re: Javascript/CSS being cached by the browser even when it has changed. Should setAddLastModifiedTimeToResourceReferenceUrl(true) be the default?

Posted by Johan Compagner <jc...@gmail.com>.
Personally i dont like an extra param, but something in the name:
/scripts/myscript_1232134323287.js

On 1/17/08, Matt Smith <ma...@gmail.com> wrote:
> Matej,
>
> A parameter on the url seems like a small price to pay to guarantee that the
> client has the correct version of the resource (IMHO).  There are other
> frameworks which do similar things by default. Is the only reason not to do
> it that the url looks a little less clean?
>
> - Matt
>
> p.s. - The grid components look nice! (http://www.inmethod.com/)
>
> On Jan 16, 2008 10:34 AM, Matej Knopp <ma...@gmail.com> wrote:
>
> > I think this would be a reasonable default behavior. Problem is that
> > it adds another parameter to resource URL, I wasn't sure that people
> > wouldn't mind, so I better left it disabled by default.
> >
> > -Matej
> >
> >
>

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


Re: Javascript/CSS being cached by the browser even when it has changed. Should setAddLastModifiedTimeToResourceReferenceUrl(true) be the default?

Posted by Matt Smith <ma...@gmail.com>.
Matej,

A parameter on the url seems like a small price to pay to guarantee that the
client has the correct version of the resource (IMHO).  There are other
frameworks which do similar things by default. Is the only reason not to do
it that the url looks a little less clean?

- Matt

p.s. - The grid components look nice! (http://www.inmethod.com/)

On Jan 16, 2008 10:34 AM, Matej Knopp <ma...@gmail.com> wrote:

> I think this would be a reasonable default behavior. Problem is that
> it adds another parameter to resource URL, I wasn't sure that people
> wouldn't mind, so I better left it disabled by default.
>
> -Matej
>
>

Re: Javascript/CSS being cached by the browser even when it has changed. Should setAddLastModifiedTimeToResourceReferenceUrl(true) be the default?

Posted by Matej Knopp <ma...@gmail.com>.
I think this would be a reasonable default behavior. Problem is that
it adds another parameter to resource URL, I wasn't sure that people
wouldn't mind, so I better left it disabled by default.

-Matej

On Jan 16, 2008 5:18 PM, Matt Smith <ma...@gmail.com> wrote:
> Hello I've been using wicket for almost a year.  I recently ran into the
> common web problem of the browser being overly aggressive on caching
> javascript files.   This is commonly solved by adding a query parm which
> changes based on the contents of the js file (checksum, time-stamp, etc).
>
> After some searching (through forums, documentation, and wiki), I found the
> following mailing list thread which alluded to the feature being done:
> http://www.nabble.com/Wicket-2%2C-modal-window%2C-ListChoice%2C-auto-completion-to6352037.html#a6386238
>
> It took some debugging through the wicket source, but I found the following
> setting which can be flipped to enable this behavior (adding a lastmodified
> url parm):
>
> getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);
>
> The reason I'm posting this message is so that anyone else encountering a
> similar problem might have a better search result that shows the solution.
> Since I've been using wicket for some time, maybe I should have known to
> look in all the settings interfaces?  However this doesn't seem like
> something you would want to turn off.
>
> Could you (wicket-committers) consider changing this to the default behavior
> since browsers have a common problem of caching those files too
> aggressively?   Using the lastmodifiedTime is a good approach to forcing the
> browser to refresh only when appropriate.   I think it's much better than
> the current default of allowing for the browser to behave strangely when the
> resource has changed on the server and requiring the user to manually clear
> their browser cache.
>
> Thanks,
>    Matt - http://netsmith.blogspot.com
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

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