Open antonyshchenko opened 9 years ago
The strategy you have made sounds like an excellent addition to the strategies offered by Optimus, and I would be happy to accept a pull request with the feature.
Great! Then I will implement it and submit a PR in a few days.
:+1:
@env0der Hi Anton! Any progress on this?
@magnars , could you please take a look at my commit? It's a rough idea (quick hack) that works for me.
How can I get rid of hardcoded "resources" path? Is there a function in optimus
that returns a base directory for assets?
Tell me if you like the idea and I will polish the code and write tests.
Optimus serves assets from the classpath, so the file location is unknown. We do pass in a folder (public
most commonly) where the assets are, but these could be coming from anywhere.
To make this work, we'll have to presume that people are serving their assets from a single directory on disk, make resources
a default, and add an option to override it. We'll also have to warn people not to use this strategy in production. :)
Thoughts?
Any progress? :)
Here it is. Sorry for long waiting - I have time for this only during weekends.
No worries, mate :) Thanks for taking the time!
I would like to tweak the way assets are cached by
optimus.strategies/serve-live-assets
.It would be nice to have an ability to pass through the
options
a function that would wrapget-optimized-assets
defined inoptimus.strategies/serve-live-assets
and implement it's own caching.The reason I need this is that for me serving an uncached assets is slow (page loading takes up to 5 seconds, probably because of several regular expressions in assets definition). TTL caching is not an option for me, because I wan't to see changes instantly when I edit the files. So I decided to implement a strategy with directory watching and cache invalidation when files in directory are changed. So far it's working fine for me, but I had to copy-paste all private functions from
optimus.strategies
.