emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

How does `app.config.static_version_urls` take effect in static url version #112

Closed laozhu closed 8 years ago

laozhu commented 8 years ago

How does app.config.static_version_urls take effect in static url version. I didn't find any docs of this config, so I searched the code and found only the below function

def static_versioning(cls):
    return (cls.application.config.static_version_urls and
              cls.application.config.static_version) or ''

I still couldn't get what this means to my final static url, any help will be appreciated, thanks.

gi0baro commented 8 years ago

Hi @laozhu, the static versioning of weppy just add the version to the URLs generated using the url() method. You just need to add the appropriate variables to your application configuration:

app.config.static_version_urls = True
app.config.static_version = "1.0.0"

Then if you build static urls using url('static', 'yourfile.js') the final url will be something like: /static/1.0.0/myfile.js

You would need to change your version number whenever you want to update the urls and invalidate the browsers' cache.

If you need something more advanced for assets versioning, you'd better go with the assets pipeline extension :)

Let me know if you need more info.

laozhu commented 8 years ago

Sorry for later reply, so static_version_urls is just a toggle, I got it, Thank you :) I have been using weppy-Assets to take care my front-end development, it's awesome tool !

gi0baro commented 8 years ago

I'm glad to hear that @laozhu, If you don't bother add a star to the weppy-Assets repo: https://github.com/gi0baro/weppy-assets

I'm gonna close this since I've added #115