์ ์ ๋ฆฌ์์ค๋?
ํด๋ผ์ด์ธํธ๋ก๋ถํฐ ์์ฒญ์ด ๋ค์ด์์ ๋, ๋ฆฌ์์ค๊ฐ ์ด๋ฏธ ๋ง๋ค์ด์ ธ ์์ด์ ๊ทธ๋๋ก ๋ณด๋ด์ฃผ๋ฉด ๋๋ ๊ฒฝ์ฐ๋ฅผ ๋งํ๋ค.
๊ธฐ๋ณธ ๋ฆฌ์์ค ์์น
โ/**โ์ด mapping์ ์ํด ์๋์ 4๊ฐ์ง ํด๋์ ์์ค์ ์ฐ๊ฒฐ์ด ๋๋ค.
classpath:/static
classpath:/public
classpath:/resources/
classpath:/META-INF/resources
์์) /hello.html => /static/hello.html
๋งตํ ์ค์ ๋ณ๊ฒฝ ๊ฐ๋ฅ
spring.mvc.static-path-pattern
์์) spring.mvc.static-path-pattern: /static/** => http://localhost:8080/static/hello.html
๋ฆฌ์์ค ์ฐพ์ ์์น ์ถ๊ฐ ๊ฐ๋ฅ
WebMvcConfigurer์ addRersourceHandlers๋ก ์ปค์คํฐ๋ง์ด์ง ํ ์ ์๋ค.
ResourceHttpRequestHandler๊ฐ ์ฒ๋ฆฌํ๋ค๊ณ ํ๋ค.
์๋์ ๋ฐฉ๋ฒ์ด ์ถ์ฒํ๋ ๋ฐฉ๋ฒ์ด๋ค.
@Configuration
public class WebConfig implements WebMvcConfigurer {
// ์ถ์ฒํ๋ ๋ฐฉ๋ฒ. ๊ธฐ์กด์ resource handler ์ ์ง, ๊ฐ๋ฐ์๊ฐ ์ํ๋ ๊ฒ๋ง ์ถ๊ฐํ ์ ์์
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/m/**")
.addResourceLocations("classpath:/m/") // ๋ฐ๋์ ์ฌ๋์๋ก ๋๋์ผ ํจ!
.setCachePeriod(20); // ์ด ๋จ์
}
}
304 ์๋ต
If-Modified-Since์ Last-Modified ํค๋๋ฅผ ๋ณด๊ณ 304 ์๋ต์ ๋ณด๋ธ๋ค.


์ด๊ฒ์ ์๋ต์ด 200์ผ ๋์ If-Modified-Since์ Last-Modified ํค๋์ด๋ค.

'Springboot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[spring boot] ์์ฃผ ๊ฐ๋จํ๊ฒ Thymeleaf ์ฌ์ฉํด๋ณด๊ธฐ (1) | 2021.01.16 |
---|---|
[spring boot] index.html, favicon (0) | 2021.01.10 |
[spring boot] WebJars ์ค jquery ์ถ๊ฐํด๋ณด๊ธฐ (0) | 2021.01.10 |
[spring boot] HttpMessageConverters (0) | 2021.01.10 |
[spring boot] Test (0) | 2021.01.09 |
[spring boot] ๋ก๊ฑฐ๋ฅผ Log4j2๋ก ๋ณ๊ฒฝํ๊ธฐ (0) | 2021.01.08 |