Skip to content
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

StaticResource url versioning #2157

Closed
sky-code opened this issue Aug 2, 2017 · 5 comments
Closed

StaticResource url versioning #2157

sky-code opened this issue Aug 2, 2017 · 5 comments
Labels

Comments

@sky-code
Copy link
Contributor

sky-code commented Aug 2, 2017

Add feature for generating urls to static files with version hash to have more control over caching in browser.

Expected behaviour

When you resolve url from StaticResource you can use append_version flag to add a hash of file (version) into url, which will change if file content changed and than for browser it's will be new url (which not exists in cache and will be reloaded)

Example

<script src="{{ url('static', filename='build/js/bundle.js', append_version=True) }}"></script>

with append_version flag StaticResource will append v param into url query string with hash of the file

/static/build/js/bundle.js?v=aDc7UcFqFqXFUOYI8crlpxDAW-i41AGSNdDP8eQebSM%3D
@asvetlov
Copy link
Member

asvetlov commented Aug 2, 2017

Not sure if I want to have the feature in aiohttp.
It looks like solving very specific problem in core while it could be done in third party easily.

Do other libraries/frameworks have the feature? Do nginx support file hashes?

@sky-code
Copy link
Contributor Author

sky-code commented Aug 2, 2017

Yes, another web frameworks already have same feature
https://www.davepaquette.com/archive/2015/05/06/link-and-script-tag-helpers-in-mvc6.aspx > Cache Busting

https://www.google.com.ua/search?q=asp.net+core+mvc+append-version

this feature implementation very similar to asp.net core mvc implementation.
I don't see any reason to reject this feature, it's fully optional (you need to use this flag to have any impact) and fully backward compatible with exists code

@asvetlov
Copy link
Member

asvetlov commented Aug 2, 2017

Ok

asvetlov pushed a commit that referenced this issue Aug 5, 2017
* add StaticResource.url append_version arg

* add 2157.feature

* 2157.feature contributor

* sort contributors.txt

* add documentation for StaticResource.url_for append_version arg #2157

* update read file code to be compatible with windows python 3.4

* fix flake8 line len issues

* add append_version param to StaticResource constructor and add_static method
docs and tests is updated to reflect changes

* add more tests and docs for StaticRoute append_version

* removed outdated comments

* add ValueError exception catching for follow_symlinks and more tests
@asvetlov
Copy link
Member

asvetlov commented Aug 6, 2017

Done by #2158

@asvetlov asvetlov closed this as completed Aug 6, 2017
@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants