-
Notifications
You must be signed in to change notification settings - Fork 4k
Management UI: serve all static assets with a control-cache header #12749
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
Conversation
30b764c to
b2439ee
Compare
|
@MarcialRosales I cannot reproduce the file reload behavior in |
|
Thanks a lot @michaelklishin for testing it. I will make it ready for review soon. |
436f809 to
3ac9e4f
Compare
|
@MarcialRosales I have chatted with @mkuratczyk about this and we think this PR is ready to go. |
398bcb7 to
adfcfa7
Compare
c9017c5 to
ce760c6
Compare
rabbit:product_version/0 should not return an 'undefined'. However, a fallback to the base version is a technique we already use in 'rabbitmq-diagnostics status', so adopt the same trick.
|
Backporting to |
4.0.5: Management UI: serve all static assets with a control-cache header (backport #12749)
This PR addreses an issue that occurs in production every time RabbitMQ releases a new version which modifies a web resource, i..e, the index.html page, or javascript file or css file. Users have to clear their cache in order to get the management ui to work again.
Proposed Changes
Add response's header that tells the browser to always check whether a web resource has been modified (using eTag) before delivering to the user. In addition to adding the corresponding
control-cacheheaders, it is necessary to add some logic to theindex.htmlso that it checks if its eTag has changed. This is something the browser does when the user requests a web resource. However,index.htmlis a special case compared to other web resources because once the user navigates for the first time to the management ui, it actually never leaves it. This is because this is a SinglePageApplication. Even when the user is kicked out of its session, the browser does not change the web resource, it is still theindex.html. When the user logs back in, it is still the sameindex.html. All the management ui is doing is dynamically changing its content. Hence, the browser never checks its eTag with the rabbitmq server.With this change, every time the user logs in, the management ui ensures the version running in the ui matches the version running in the server and if they do not match, it reloads the index.html and with it and thanks to the eTag in all the web resources (javascript and css files), it loads all the latest files into the browser.
This means that if the user has a live session and RabbitMQ is redeployed with a newer version, the user would have logout. In all other cases, the reload is totally transparent to the user.
Context:
Acceptance Test
Reminder: Never refresh the page or modify the url in the browser once you enter it for the first time.
/tmp/rabbitmq.confwith the following configuration:deps/rabbitmq_management/priv/www/index.htmland modify<title>RabbitMQ Management</title>to<title>1. RabbitMQ Management</title>deps/rabbitmq_management/priv/www/js/global.jsand add the following line to the bottom of the filedeps/rabbitmq_management/priv/www/css/main.cssand add the following line to the bottom of the file/tmp/rabbitmq.confand uncomment the line#product.version = 4.1.0+beta.1.22.fake.1make run-broker RABBITMQ_CONFIG_FILE=/tmp/rabbitmq.conf1. RabbitMQ Managementmain.cssandglobal.jsIf you repeat these steps on
mainbranch, make sure you clear your cache first. You will see that on step 13, the title has not changed.