Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recognize text/javascript as valid js mimetype for caching purposes (t…
…ensorflow#5746) Recently the test core_plugin_test.py::test_js_cache began to fail in some environments with the following error: ``` ... core_plugin_test.py", line 196, in test_js_cache self.assertEqual( AssertionError: - private, max-age=86400 + no-cache, must-revalidate ``` The root cause is that these systems have now been configured to return 'text/javascript' as the mimetype for js files, where they were previously returning 'application/javascript'. This means the 'Cache-Control' header was not set by this line: https://cs.opensource.google/tensorflow/tensorboard/+/master:tensorboard/plugins/core/core_plugin.py;l=137;drc=c061b659f50cde9dd9da5aa906ecb682ecdc68d4 ``` expires = ( JS_CACHE_EXPIRATION_IN_SECS if request.args.get("_file_hash") and mimetype == "application/javascript" else 0 ) ``` After further investigation (thanks @nfelt!) we determined that the change in mimetype is likely intentional after the recent publishing of RFC 9239 (https://www.rfc-editor.org/rfc/rfc9239), where 'text/javascript' becomes the standard mimetype for js files. We decided, therefore, to change the Cache-Control-setting logic to also recognize 'text/javascript'. Note, in practice, the change in mimetype had no impact on running tensorboards thanks to the logic added in tensorflow#3128, which always ensures ".js" is mapped to mimetype "application/javascript" but does it at a higher level (ie outside either core plugin or the http utils).
- Loading branch information