RE: Time to live for classpath references
Hi Peter, There is a RFE to support caching control directly in the Restlet API: "Support caching HTTP headers" http://restlet.tigris.org/issues/show_bug.cgi?id=213 Otherwise, there is a "timeToLive" parameter on local connectors such as CLAP, FILE: http://www.restlet.org/documentation/snapshot/engine/org/restlet/engine/loca l/LocalClientHelper.html By default the value is 600 second but due to a bug, it wasn't applied to the CLAP representations' expiration date. I've fixed this in SVN trunk and 1.1 branch. Let me know if it works for you! Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -Message d'origine- De : news [mailto:n...@ger.gmane.org] De la part de Peter Becker Envoyé : lundi 23 février 2009 01:07 À : discuss@restlet.tigris.org Objet : Re: Time to live for classpath references Thanks, I'll try that -- at least you saved me from finding the hack myself :-) Is there an RFE to vote upon? I think controlling the caches can be quite important, especially if you have lots of small objects. I'd personally even go as far as having a parameter on the constructor of directory that toggles infinite caching. If the resource is truly static with a URI encoding its revision, then you will never need the cache expiry. Peter Rob Heittman wrote: > We still do this: > > http://gogoego.googlecode.com/svn/trunk/modules/com.solertium.util.restlet/s rc/com/solertium/util/restlet/ClapCacheDirectory.java > > If there's a better way, I'd love to adopt it too. > > On Thu, Feb 19, 2009 at 11:29 PM, Peter Becker > > wrote: >> Hello, >> >> I'm using the CLAP protocol to get static content such as JavaScript >> delivered. I'd like to have those expire way down in the future since >> I use URLs that encode the file version and some of the JS libraries >> I use create quite a few hits to the server. I'm using Restlet 1.1.2 >> with the Restlet engine. >> >> I've tried a number of things, but nothing seems to work. What I am >> currently doing is this: >> >>public static void main(String[] args) throws Exception { >>Component component = new Component(); >>component.getServers().add(Protocol.HTTP, >> configuration.getHttpPort()); >> component.getClients().add(Protocol.CLAP).getContext().getParameters().add(" timeToLive","604800"); >> >>component.getDefaultHost().attach(new Pronto()); >> >>component.start(); >>} >> >> and in createRoot() I have a Router to which I attach a directory >> like >> this: >> >>router.attach("/javascript", >>new Directory(getContext(), >> LocalReference.createClapReference(LocalReference.CLAP_THREAD, >> "/javascript"))); >> >> I can't see any relevant header in the responses, though -- somehow >> setting the parameter doesn't seem to have any impact. Am I missing >> something? >> >> BTW: the "Server" header says "Noelios-Restlet-Engine/1.1..2", which >> I suppose has a dot too many. >> >> Regards, >> Peter >> >> -- >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=11963 39 >> > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=11982 52 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=12116 67 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1245414
Re: Time to live for classpath references
Thanks, I'll try that -- at least you saved me from finding the hack myself :-) Is there an RFE to vote upon? I think controlling the caches can be quite important, especially if you have lots of small objects. I'd personally even go as far as having a parameter on the constructor of directory that toggles infinite caching. If the resource is truly static with a URI encoding its revision, then you will never need the cache expiry. Peter Rob Heittman wrote: > We still do this: > > http://gogoego.googlecode.com/svn/trunk/modules/com.solertium.util.restlet/src/com/solertium/util/restlet/ClapCacheDirectory.java > > If there's a better way, I'd love to adopt it too. > > On Thu, Feb 19, 2009 at 11:29 PM, Peter Becker > wrote: >> Hello, >> >> I'm using the CLAP protocol to get static content such as JavaScript >> delivered. I'd like to have those expire way down in the future since I >> use URLs that encode the file version and some of the JS libraries I use >> create quite a few hits to the server. I'm using Restlet 1.1.2 with the >> Restlet engine. >> >> I've tried a number of things, but nothing seems to work. What I am >> currently doing is this: >> >>public static void main(String[] args) throws Exception { >>Component component = new Component(); >>component.getServers().add(Protocol.HTTP, >> configuration.getHttpPort()); >> component.getClients().add(Protocol.CLAP).getContext().getParameters().add("timeToLive","604800"); >> >>component.getDefaultHost().attach(new Pronto()); >> >>component.start(); >>} >> >> and in createRoot() I have a Router to which I attach a directory like >> this: >> >>router.attach("/javascript", >>new Directory(getContext(), >> LocalReference.createClapReference(LocalReference.CLAP_THREAD, >> "/javascript"))); >> >> I can't see any relevant header in the responses, though -- somehow >> setting the parameter doesn't seem to have any impact. Am I missing >> something? >> >> BTW: the "Server" header says "Noelios-Restlet-Engine/1.1..2", which I >> suppose has a dot too many. >> >> Regards, >> Peter >> >> -- >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1196339 >> > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1198252 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1211667
Re: Time to live for classpath references
We still do this: http://gogoego.googlecode.com/svn/trunk/modules/com.solertium.util.restlet/src/com/solertium/util/restlet/ClapCacheDirectory.java If there's a better way, I'd love to adopt it too. On Thu, Feb 19, 2009 at 11:29 PM, Peter Becker wrote: > Hello, > > I'm using the CLAP protocol to get static content such as JavaScript > delivered. I'd like to have those expire way down in the future since I use > URLs that encode the file version and some of the JS libraries I use create > quite a few hits to the server. I'm using Restlet 1.1.2 with the Restlet > engine. > > I've tried a number of things, but nothing seems to work. What I am > currently doing is this: > >public static void main(String[] args) throws Exception { >Component component = new Component(); >component.getServers().add(Protocol.HTTP, > configuration.getHttpPort()); > > component.getClients().add(Protocol.CLAP).getContext().getParameters().add("timeToLive","604800"); > >component.getDefaultHost().attach(new Pronto()); > >component.start(); >} > > and in createRoot() I have a Router to which I attach a directory like this: > >router.attach("/javascript", >new Directory(getContext(), >LocalReference.createClapReference(LocalReference.CLAP_THREAD, > "/javascript"))); > > I can't see any relevant header in the responses, though -- somehow setting > the parameter doesn't seem to have any impact. Am I missing something? > > BTW: the "Server" header says "Noelios-Restlet-Engine/1.1..2", which I > suppose has a dot too many. > > Regards, > Peter > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1196339 > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1198252