Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.EncodedResourceResolver;

import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -41,7 +42,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
.getStaticPath()
+ "assets/",
"classpath:/static/assets/")
.setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS).cachePublic());
.setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS).cachePublic())
.resourceChain(true)
.addResolver(new EncodedResourceResolver());

// Don't cache index.html - it needs to be fresh to reference latest hashed assets
// Note: index.html is handled by ReactRoutingController for dynamic processing
Expand All @@ -51,7 +54,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ stirling.software.common.configuration.InstallationPathConfig
.getStaticPath(),
"classpath:/static/")
.setCacheControl(CacheControl.noCache().mustRevalidate());
.setCacheControl(CacheControl.noCache().mustRevalidate())
.resourceChain(true)
.addResolver(new EncodedResourceResolver());

// Handle all other static resources (js, css, images, fonts, etc.)
// Check customFiles/static first for user overrides
Expand All @@ -61,7 +66,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ stirling.software.common.configuration.InstallationPathConfig
.getStaticPath(),
"classpath:/static/")
.setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS));
.setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS))
.resourceChain(true)
.addResolver(new EncodedResourceResolver());
}

@Override
Expand Down Expand Up @@ -158,7 +165,8 @@ public void addCorsMappings(CorsRegistry registry) {
} else {
// Default to allowing all origins when nothing is configured
logger.debug(
"No CORS allowed origins configured in settings.yml (system.corsAllowedOrigins); WebMvcConfig allowing all origins.");
"No CORS allowed origins configured in settings.yml"
+ " (system.corsAllowedOrigins); WebMvcConfig allowing all origins.");
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
Expand Down
31 changes: 31 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"typescript": "^5.9.2",
"typescript-eslint": "^8.44.1",
"vite": "^7.3.2",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-static-copy": "^3.1.4",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.2.4"
Expand Down
11 changes: 11 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from "vite-tsconfig-paths";
import { viteStaticCopy } from "vite-plugin-static-copy";
import viteCompression from "vite-plugin-compression";

const VALID_MODES = [
"core",
Expand Down Expand Up @@ -82,6 +83,16 @@ export default defineConfig(({ mode }) => {
},
],
}),
viteCompression({
algorithm: "gzip",
ext: ".gz",
threshold: 1024,
}),
viteCompression({
algorithm: "brotliCompress",
ext: ".br",
threshold: 1024,
}),
],
server: {
host: true,
Expand Down
Loading