Merge pull request #11903 from surajshetty3416/fix-login-page-failure

fix(website): Bust cache by passing build_version to link and script src
This commit is contained in:
mergify[bot] 2020-11-09 11:52:26 +00:00 committed by GitHub
commit 39b549291f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 15 deletions

View file

@ -30,11 +30,11 @@
{%- if theme.name != 'Standard' -%}
<link type="text/css" rel="stylesheet" href="{{ theme.theme_url }}">
{%- else -%}
<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web-b4.css">
<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web-b4.css?ver={{ build_version }}">
{%- endif -%}
{%- for link in web_include_css %}
<link type="text/css" rel="stylesheet" href="{{ link|abs_url }}">
<link type="text/css" rel="stylesheet" href="{{ link|abs_url }}?ver={{ build_version }}">
{%- endfor -%}
{%- endblock -%}
@ -94,12 +94,12 @@
{% block base_scripts %}
<!-- js should be loaded in body! -->
<script type="text/javascript" src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/assets/js/frappe-web.min.js"></script>
<script type="text/javascript" src="/assets/js/frappe-web.min.js?ver={{ build_version }}"></script>
<script type="text/javascript" src="/assets/js/bootstrap-4-web.min.js"></script>
{% endblock %}
{%- for link in web_include_js %}
<script type="text/javascript" src="{{ link | abs_url }}"></script>
<script type="text/javascript" src="{{ link | abs_url }}?ver={{ build_version }}"></script>
{%- endfor -%}
{%- block script %}

View file

@ -721,3 +721,11 @@ def get_file_size(path, format=False):
num /= 1024
return "{0:.1f}{1}{2}".format(num, 'Yi', suffix)
def get_build_version():
try:
return str(os.path.getmtime(os.path.join(frappe.local.sites_path, '.build')))
except OSError:
# .build can sometimes not exist
# this is not a major problem so send fallback
return frappe.utils.random_string(8)

View file

@ -275,8 +275,7 @@ def get_page_info(path, app, start, basepath=None, app_path=None, fname=None):
# extract properties from controller attributes
load_properties_from_controller(page_info)
# if not page_info.title:
# print('no-title-for', page_info.route)
page_info.build_version = frappe.utils.get_build_version()
return page_info

View file

@ -36,7 +36,7 @@ def get_context(context):
context.update({
"no_cache": 1,
"build_version": get_build_version(),
"build_version": frappe.utils.get_build_version(),
"include_js": hooks["app_include_js"],
"include_css": hooks["app_include_css"],
"sounds": hooks["sounds"],
@ -82,11 +82,3 @@ def get_desk_assets(build_version):
"boot": data["boot"],
"assets": assets
}
def get_build_version():
try:
return str(os.path.getmtime(os.path.join(frappe.local.sites_path, '.build')))
except OSError:
# .build can sometimes not exist
# this is not a major problem so send fallback
return frappe.utils.random_string(8)