I've been thinking about generating a class using sbt that contains a map that contains the md5 hashes of contents of each asset file (css or js) keyed by the path+name of the asset during build time.
I think this should be effective since the contents don't change after a build. This way I can append that hash as a url parameter to the end of the asset url and/or use it as an etag to optimize proxy and browser caching.
I think this can be better than the Last Modified Time since effctively every time you deploy a play app you get a new timestamp which will force the users to download the file even though it might not have changed.
What do you guys think? Is it worth using this approach in Play's Asset controller?
Thanks,
Drew
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
No response?On Apr 9, 2012, at 11:48 PM, Drew Kutcharian <dr...@venarc.com> wrote:
> Hi All,
>
> I've been thinking about generating a class using sbt that contains a map that contains the md5 hashes of contents of each asset file (css or js) keyed by the path+name of the asset during build time.
>
> I think this should be effective since the contents don't change after a build. This way I can append that hash as a url parameter to the end of the asset url and/or use it as an etag to optimize proxy and browser caching.
>
> I think this can be better than the Last Modified Time since effctively every time you deploy a play app you get a new timestamp which will force the users to download the file even though it might not have changed.
>
> What do you guys think? Is it worth using this approach in Play's Asset controller?
>
> Thanks,
>
> Drew
>
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-framework@googlegroups.com.
> To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/18AC0VINw9IJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/jKPlYUOtwjAJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/ylR28bBAuZYJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
Even if I can force the CDN to cache the assets without revalidating,
clients still end up sending unnecessary requests to the CDN.
I added the link to this conversation to the lighthouse ticket. BTW, the lighthouse ticket looks incomplete to me, maybe something happened during posting?
-- Drew
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/iY0El86ulmwJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
Doing it at runtime is simpler? (add some code or subclass the Asset
controller vs figuring out how to deal with sbt)
Yes; I was talking about the Asset controller because I thought
routes.Assets is generated from controllers.Assets?
> basically www.myapp.com/asset/images/foo.png?v1 instead
> of www.myapp.com/asset/images/foo.png
>
> Would that work with reverse proxies ?
Yes. But some proxies won't cache resources with a '?' [1], so it
might be a good idea to use foo.v1.png instead of foo.png?v1.
[1] https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
As far as proxies not caching resources with an '?', the URL can be changes to www.myapp.com/assset/images/foo.png/<md5(foo.png)>
-- Drew
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
Worst case the hash is calculated several times?
> As far as proxies not caching resources with an '?', the URL can be changes to www.myapp.com/assset/images/foo.png/<md5(foo.png)>
That should work, though I'd rather keep the file extension at the end.
cheers,
Drew
Doing it runtime is definitely easier but at the cost of having a mutable state in a possibly hot area and risk of race conditions. (I'm not even sure if it can be done, how would you know the hash of a resource without first computing it?)As far as proxies not caching resources with an '?', the URL can be changes to www.myapp.com/assset/images/foo.png/<md5(foo.png)>
-- Drew
On Apr 10, 2012, at 6:35 PM, Eric Jain wrote:
> On Tue, Apr 10, 2012 at 18:15, Julien Tournay <boud...@gmail.com> wrote:
>> You don't have to change the Asset I think.
>> If the reverse router was just adding a query param to the path, the Asset
>> would still work.
>
> Yes; I was talking about the Asset controller because I thought
> routes.Assets is generated from controllers.Assets?
>
>
>> basically www.myapp.com/asset/images/foo.png?v1 instead
>> of www.myapp.com/asset/images/foo.png
>>
>> Would that work with reverse proxies ?
>
> Yes. But some proxies won't cache resources with a '?' [1], so it
> might be a good idea to use foo.v1.png instead of foo.png?v1.
>
> [1] https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
>
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-framework@googlegroups.com.
> To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.