[MGNLRES-152] Generate links to resources, and use selectors with ~ to generate farFutureCaching URLs for resources Created: 22/May/15 Updated: 29/Mar/22 Resolved: 23/Jun/15 |
|
| Status: | Closed |
| Project: | Magnolia Resources Module |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Magnolia International | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Template: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Date of First Response: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Team: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
The model class used for resources (info.magnolia.module.resources.Resource) currently generates its "far future caching" links with dots, e.g /resources/foo/bar.2015-05-22-16-00-35-123.cache.css. This is then "converted" to using ~ by a virtual URI configured in the cache module, which was added via Finally, the RepositoryMappingFilter strips out the ~ from the current uri set in AggregationState, and sets handle and currentNode. While convoluted, this works, as long as we load resources after this filter, e.g with the rendering mechanism and the special Resource*Renderers. If we serve resources via a Servlet, the current uri in AggregationState still has ~'s in it, since servlets are interrupting the filter chain before it reaches the RepositoryMappingFilter. Besides, using a servlet has the added benefit that we can use pathInfo (as opposed to the complete URI, which includes the path to the servlet). Suggested approach:
Essentially, this is all due to Meanwhile, we should also factor out the far-future-link generation:
We'll also need to investigate browser cache, i.e /modules/cache/config/configurations/default/browserCachePolicy/policies/farFuture/voters/dotCacheExtension |
| Comments |
| Comment by Magnolia International [ 03/Jun/15 ] |
|
Started work on feature/ |
| Comment by Magnolia International [ 09/Jun/15 ] |
|
Pushed, cleaned up and squashed on feature/ |
| Comment by Magnolia International [ 12/Jun/15 ] |
|
The info.magnolia.module.resources.Resource and info.magnolia.module.resources.CssFile classes will be moved to the site module where they belong (next to Site- and Theme- definitions), possibly renamed to something like Site/Page/ResourceDefinition. The resources module now provides a ResourceLinker, which is used by the above and by the ResourcesServlet; this new component is able to provide links (URLs) from a ResourcePath as well as decode them. We've also made the ResourcesServlet a SelfMappingServlet, so the mapping is configured in the resources module and can be used to generate links. |
| Comment by Magnolia International [ 18/Jun/15 ] |
|
see |
| Comment by Philip Mundt [ 23/Jun/15 ] |
|
ResourceLinker needs to use a Provider for the ResourceModule (in ctor) in order to prevent: info.magnolia.jcr.node2bean.Node2BeanException: com.google.inject.ProvisionException: Guice provision errors: 1) Module instance for module [resources] not available, most likely because the module has not yet been started. Inject a Provider<> instead to get access to the module instance when it's available. at info.magnolia.objectfactory.guice.GuiceComponentConfigurationModule.bindProvider(GuiceComponentConfigurationModule.java:190) while locating info.magnolia.module.resources.ResourcesModule for parameter 1 at info.magnolia.module.resources.ResourceLinker.<init>(ResourceLinker.java:73) at info.magnolia.objectfactory.guice.GuiceComponentConfigurationModule.bindImplementation(GuiceComponentConfigurationModule.java:158) while locating info.magnolia.module.resources.ResourceLinker |
| Comment by Magnolia International [ 23/Jun/15 ] |
|
Indeed; we now inject a Provider<ResourcesModule> in ResourceLinker. This is due to the rendering module, which initializes template definitions. Some definitions use ResourceLinker indirectly. The rendering module currently can't depend on resources-module (circular dep with templating) |