[ 
https://issues.apache.org/jira/browse/SLING-12764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949617#comment-17949617
 ] 

Abhishek Garg commented on SLING-12764:
---------------------------------------

Adding more Jöerg comment,

We currently cache a list of vanity URLs locally and update it periodically. 
When a request comes in with a vanity URL, we first check against this cache. 
If the vanity URL is found and the corresponding content is available in our 
{{httpd}} module cache, we serve it directly. Otherwise, we need to make a 
separate call for each unmatched URI, which increases the number of requests.

> Add API to getALL Vanity Paths
> ------------------------------
>
>                 Key: SLING-12764
>                 URL: https://issues.apache.org/jira/browse/SLING-12764
>             Project: Sling
>          Issue Type: Improvement
>          Components: API, ResourceResolver
>            Reporter: Abhishek Garg
>            Priority: Major
>
> *Summary*
> Introduce a new API method in the An {{ResourceResolver}} interface to expose 
> vanity path mappings that are already calculated and cached internally.
> ----
> *Description*
> Currently, the {{ResourceResolver}} calculates and caches all vanity paths 
> internally (see {{MapEntries.initializeVanityPaths()}} and 
> {{{}VanityPathHandler{}}}), controlled by the configuration property 
> {{{}resource.resolver.vanity.paths.enabled{}}}.
> However, downstream systems that require access to vanity paths must 
> *recalculate* them independently, resulting in:
>  * *Duplicate computation* — The same JCR query is executed multiple times.
>  * *Increased memory usage* — Multiple caches holding the same data.
>  * *Potential inconsistencies* — Different systems might process vanity paths 
> differently.
> ----
> *Proposed Solution*
> Expose the existing vanity path cache through a new method in the 
> {{ResourceResolver}} interface:
> /**
>  * Returns a mapping from vanity paths to their corresponding target resource 
> paths.
>  *
>  * @return An unmodifiable map of vanity paths to their target resource 
> paths, or an empty map if vanity paths are disabled.
>  * @since 2.28.0 (or the next appropriate version)
>  */
> Map<String, List<String>> getVanityPathMappings();
>  
> The {{ResourceResolverImpl}} would implement this by returning a view of 
> internal maintenance cache
> ----
> *Benefits*
>  * *Reduces system resource usage* by eliminating redundant calculations.
>  * *Ensures a consistent view* of vanity paths across all components.
>  * *Simplifies implementation* of downstream systems that depend on vanity 
> path data.
>  * *Enables more efficient architectures* by leveraging already computed and 
> cached information.
> ----
> *Repositories Impacted*
>  * 
> [{{sling-org-apache-sling-api}}|https://github.com/apache/sling-org-apache-sling-api]
>  * 
> [{{sling-org-apache-sling-resourceresolver}}|https://github.com/apache/sling-org-apache-sling-resourceresolver]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to