This is an automated email from the ASF dual-hosted git repository.
kotman12 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new a2bfbf7fa29 SOLR-18615 don't cache admin resources (#5300)
a2bfbf7fa29 is described below
commit a2bfbf7fa29679e0919514514503b6c21e3a6951
Author: Luke Kot-Zaniewski <[email protected]>
AuthorDate: Thu Nov 5 21:24:03 2026 -0500
SOLR-18615 don't cache admin resources (#5300)
Admin UI static files are now served with `Cache-Control: no-cache`, so
after an upgrade the browser revalidates them instead of mixing in files cached
from the previous Solr version. Such mixing could break the UI, for example by
showing bogus "Permission failure" banners.
---
changelog/unreleased/SOLR-18615-admin-ui-stale-cache.yml | 8 ++++++++
solr/packaging/test/test_adminconsole_urls.bats | 10 ++++++++++
.../src/java/org/apache/solr/embedded/JettySolrRunner.java | 1 +
solr/webapp/web/WEB-INF/web.xml | 5 +++++
solr/webapp/web/index.html | 2 +-
5 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/changelog/unreleased/SOLR-18615-admin-ui-stale-cache.yml
b/changelog/unreleased/SOLR-18615-admin-ui-stale-cache.yml
new file mode 100644
index 00000000000..dbe787712d2
--- /dev/null
+++ b/changelog/unreleased/SOLR-18615-admin-ui-stale-cache.yml
@@ -0,0 +1,8 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+title: 'Admin UI static files are now served with `Cache-Control: no-cache`,
so after an upgrade the browser revalidates them instead of mixing in files
cached from the previous Solr version. Such mixing could break the UI, for
example by showing bogus "Permission failure" banners.'
+type: fixed
+authors:
+ - name: Luke Kot-Zaniewski
+links:
+ - name: SOLR-18615
+ url: https://issues.apache.org/jira/browse/SOLR-18615
diff --git a/solr/packaging/test/test_adminconsole_urls.bats
b/solr/packaging/test/test_adminconsole_urls.bats
index bc468a75470..8a79f6e77b3 100644
--- a/solr/packaging/test/test_adminconsole_urls.bats
+++ b/solr/packaging/test/test_adminconsole_urls.bats
@@ -51,6 +51,16 @@ teardown() {
assert_output --partial "{"
}
+@test "assert admin console static assets are revalidated and versioned" {
+ run solr start
+
+ run curl -s -I http://localhost:${SOLR_PORT}/solr/libs/solr/index.js
+ assert_output --partial "Cache-Control: no-cache"
+
+ run curl -s http://localhost:${SOLR_PORT}/solr/
+ refute_output --regexp '(src|href)="[^"]+\.(js|css)"'
+}
+
@test "assert CSP header contains custom connect src URLs" {
# Set custom CSP connect-src URLs via system property
local
csp_urls="http://example1.com/token,https://example2.com/path/uri1,http://example3.com/oauth2/uri2"
diff --git
a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java
b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java
index fa06692b00d..90f5b7226b5 100644
--- a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java
+++ b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java
@@ -352,6 +352,7 @@ public class JettySolrRunner implements SolrBackend {
staticHolder.setHeldClass(ResourceServlet.class);
staticHolder.setInitParameter("pathInfoOnly", "false");
staticHolder.setInitParameter("dirAllowed", "false");
+ staticHolder.setInitParameter("cacheControl", "no-cache");
for (String pathSpec :
new String[] {
"/partials/*", "/libs/*", "/css/*", "/js/*", "/img/*",
"/templates/*", "/ui/*"
diff --git a/solr/webapp/web/WEB-INF/web.xml b/solr/webapp/web/WEB-INF/web.xml
index d878be3fdd7..03ce79e77ef 100644
--- a/solr/webapp/web/WEB-INF/web.xml
+++ b/solr/webapp/web/WEB-INF/web.xml
@@ -91,6 +91,11 @@
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
+ <!-- Revalidate on each load so a browser never mixes UI assets from
different Solr versions -->
+ <init-param>
+ <param-name>cacheControl</param-name>
+ <param-value>no-cache</param-value>
+ </init-param>
</servlet>
<!-- Map static Admin UI resources to the static servlet -->
<servlet-mapping>
diff --git a/solr/webapp/web/index.html b/solr/webapp/web/index.html
index 85abdcebe32..bfb5c60ddc7 100644
--- a/solr/webapp/web/index.html
+++ b/solr/webapp/web/index.html
@@ -68,7 +68,7 @@ limitations under the License.
<script src="libs/highlight.js-11.12.0.min.js?_=${version}"></script>
<script src="libs/d3.js?_=${version}"></script>
<script src="libs/ui-grid.min.js?_=${version}"></script>
- <script src="libs/solr/index.js"></script>
+ <script src="libs/solr/index.js?_=${version}"></script>
<script src="libs/jquery-ui.min.js?_=${version}"></script>
<script src="libs/angular-utf8-base64.min.js?_=${version}"></script>
<script src="libs/jssha-3.3.1-sha256.min.js?_=${version}"></script>