You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2013/12/17 14:59:08 UTC

[jira] [Resolved] (WICKET-4343) Add 'static' indicator near start of URL for static resources to allow fast detection by filters

     [ https://issues.apache.org/jira/browse/WICKET-4343?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-4343.
-------------------------------------

    Resolution: Won't Fix

/wicket/resource/... prefix is used for all resources which are not mounted explicitly.
Usually those are static resources contributed by PackageResourceReference (e.g. JS, CSS, images).

Dynamic resources are usually mounted with WebApplication#mountResource("customPath", someResReference).

The only exception I can think of is SharedResourceReference, but it is not used wildly.

> Add 'static' indicator near start of URL for static resources to allow fast detection by filters
> ------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4343
>                 URL: https://issues.apache.org/jira/browse/WICKET-4343
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.4
>         Environment: Any
>            Reporter: Chris Colman
>            Priority: Minor
>
> While it is possible to affect the 'prefix' of static package resource URLs this prefix appears near the end of the URL, after the namespace, resource identifier, full path name and class name. Adding a prefix towards the end of the URL that distinguishes static resources so that third party filters can detect them and avoid establishing a session means each filter needs to perform full scan of every URL it receives to test if the 'prefix' is present.
> It's substantially quicker to test the first few chars of a URL string for a match with 'startsWith' than it is to iterate through to almost the end of each URL string to see if it 'contains' a substring. Any URL will fail to match on comparison of the first character if they don't have a 'w' (to match wicket/resource) at the beginning which makes startsWith a 'fast fail' test for most URLs it processes.
> I think that's probably why the Servlet Spec chooses to do filter and servlet path matching via a 'starts with' strategy without support for wildcards except at the very end of a pattern.
> Many of the URLs requested are very long and it would be preferable if wicket and third party filters could avoid string parsing of many thousands of super long URLs wherever they can - there's already enough of that going on without adding to the CPU's work load.
> Looking at the code it would probably be easy to do in BasicResourceReferenceMapper.java.
> Maybe to not disturb the number of segments used for resources it could be less invasive to change the start path of resources guaranteed to be stateless/static (not requiring a session to service requests for) it could simply replace the second segment provided by the getResourceIdentifier() so that the path ends up as
> /wicket/static-resource 
> if static and
> /wicket/resource
> if not static.
> Perhaps getResourceHandler could take boolean static parameter.



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)