-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cachebust_match argument not documented; not allowed by add_static_view #2675
Comments
And if it wasn't clear, what we've been doing is serving all the static files at
so that the relative urls in CSS and more importantly JavaScript as we're using on-demand loading for various frameworks, including loading locales for libraries and such, can continue to work with relative URLs, and we have to rewrite absolutely nothing to get cache busting work correctly everywhere, and every file, including that 16x16 pixel logo added that included css will also be cachebusted, ensuring that nothing needs to be flushed in CDN. |
Unfortunately we had to remove the ability for the static views to remove cache busting tokens because it is impossible to do so sanely. See my comment here: #2186 (comment) Also see this comment: #2171 (comment) I am not sure why Your best bet is to write a tween that re-writes the URL on the way in. |
Confirmed with @mmerickel on IRC that |
That feature was intended to be removed, however it looks like the static_view support slipped through the cracks. That is not to say that your use-case is invalid, or shouldn't be discussed. The main reason this is not solved generally in Pyramid (right now) is that we decided not to make any assumptions about the URL that would be generated by your cachebuster. This means it may not be mounted in I hope this will a) help you solve your problem and b) give you some fodder for discussing this further if we are to solve it in Pyramid. The comments linked above by @bertjwregeer are still relevant. |
I've created a PR that removes |
@ztane Your issue is easily solved by simply not using the cache busting framework. A global cache busting token is quite trivial: config.add_static_view('static/' + token, 'myapp:static', http_cache=10 * 365 * 24 * 3600)
# let's redirect other requests to tokenized versions
config.add_route('redirect-static', '/static/*subpath')
def static_redirect_view(request):
next_url = request.static_url('myapp:static/' + '/'.join(request.subpath), _query=request.GET)
return HTTPFound(next_url)
config.add_view(static_redirect_view, route_name='redirect-static') |
Yeah that was what we were using in pyramid 1.5. |
We merged #2681 which removes this undocumented argument. You'll need to come up with another way to serve the cache busted urls. Right now pyramid only helps generate them. Several possible solutions were mentioned already in this issue. |
We are generating one path segment cachebreaker for all of our static files (our static files do not really change that often, only in release cycles, thus it is OK to reload all of them whenever a new release occurs); this allows us to use relative urls without manifests and allows things like require.js work painlessly as well; but for this we utilized a modified
PathSegmentCacheBuster
.Now that the new cachebusting scheme has come, it is not possible to do this any longer, since
add_static_view
doesn't like seeing cache tokens any more.static_view
seems to supportcachebust_match
which could be used to remove the busting token from the subpath, butadd_static_view
thinks an argument by that name is a custom predicate instead.The text was updated successfully, but these errors were encountered: