Skip to content

Invisible Rewrites (mod_rewrite) - Asset Manager uses the pre-rewritten path to resolve #176

@mtudor

Description

@mtudor

Hi guys, looking for a bit of input on this one please. We've just implemented a cache busting module which adds a rewrite rule to catch paths of the format (for example) /my/path/myfile.XX.XX.XX.js (where XX.XX.XX is a version number) and invisibly rewrite these to /my/path/myfile.js.

We are using the PathStackResolver, and AssetManager attempts to locate an asset with the pre-rewritten name including the version number. This doesn't find anything and the file access fails. My initial thought was whether AssetManager should actually be using the REDIRECT_URL parameter to grab the post-rewritten name excluding the version number? For example, this change:

https://github.com/RWOverdijk/AssetManager/blob/master/src/AssetManager/Service/AssetManager.php#L194

$fullPath   = $request->getServer('REDIRECT_URL') ?: $uri->getPath();

My concerns:

  • the reliability of REDIRECT_URL (possibly semi-negated by a $uri->getPath() fallback?).
  • whether there are circumstances you would actually want the pre-rewritten url, possibly in resolvers that are not path related.

I've been talking in terms of cache-busting and version numbers but of course this would apply to any invisible rewrite situation... Appreciate your thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions