From ea87504e7b95823e3f4ba15147ba6b2950d2c11d Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 28 Feb 2025 21:56:32 +0400 Subject: [PATCH] #4 -- Enable caching --- .../java/ru/ulstu/fc/config/SecurityConfiguration.java | 2 +- .../ru/ulstu/fc/rule/controller/FuzzyRuleController.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/fc/config/SecurityConfiguration.java b/src/main/java/ru/ulstu/fc/config/SecurityConfiguration.java index be6b4ea..a07da1e 100644 --- a/src/main/java/ru/ulstu/fc/config/SecurityConfiguration.java +++ b/src/main/java/ru/ulstu/fc/config/SecurityConfiguration.java @@ -28,7 +28,7 @@ public class SecurityConfiguration { log.debug("Security enabled"); http - .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) + .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)) .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(auth -> auth.requestMatchers("/").permitAll() diff --git a/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleController.java b/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleController.java index c0c291c..a19f79f 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleController.java @@ -1,5 +1,6 @@ package ru.ulstu.fc.rule.controller; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -64,14 +65,18 @@ public class FuzzyRuleController { @ResponseBody @GetMapping("/getVariables/{projectId}") - public List getVariables(@PathVariable("projectId") Integer projectId) { + public List getVariables(@PathVariable("projectId") Integer projectId, + final HttpServletResponse response) { + response.addHeader("Cache-Control", "max-age=60, must-revalidate, no-transform"); //TODO: return DTO without terms return variableService.getAllByProject(projectId); } @ResponseBody @GetMapping("/getFuzzyTerms/{variableId}") - public List getTerms(@PathVariable("variableId") Integer variableId) { + public List getTerms(@PathVariable("variableId") Integer variableId, + final HttpServletResponse response) { + response.addHeader("Cache-Control", "max-age=60, must-revalidate, no-transform"); return fuzzyTermService.getByVariableId(variableId); } }