Cache Busting - Fingerprinting

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Cache Busting - Fingerprinting

perky
Can cache busting - fingerprinting be accomplished with Spring-Thymeleaf?

Per documentation that I've been reading the configuration class below should enable this.  But I'm not seeing unique signatures/fingerprints in the generated HTML.

Configuration class:
@EnableWebMvc
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

                   VersionResourceResolver versionResourceResolver = new VersionResourceResolver()
                                                                                                .addVersionStrategy(new ContentVersionStrategy(), "/**");

                registry.addResourceHandler("/resources/**")
                .addResourceLocations("/resources/")
                .setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS))
                .resourceChain(true)
                .addResolver(versionResourceResolver)
                ;
    }
 
    @Bean
    public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
      return new ResourceUrlEncodingFilter();
    }
}

This is from my template where I'm trying to reference fingerprinted CSS and JavaScript files.  Notice 2 different types of references.  Neither works.

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<base th:href="@{/}" />
<meta charset="utf-8"></meta>
	<link rel="stylesheet" th:href="${@mvcResourceUrlProvider.getForLookupPath('resources/base/css/MFSWeb.css')}" />
	<link rel="stylesheet" th:href="@{resources/base/css/MFSWeb.css}" />
	
  	<script th:src="${@mvcResourceUrlProvider.getForLookupPath('resources/Env/js/envListing.js')}" type="text/javascript"></script>
  	<script th:src="@{resources/Env/js/envListing.js}" type="text/javascript"></script>
</head>

This is what the HTML source looks like.  Notice no fingerprint.

<!DOCTYPE html>
<html lang="en">
<head>
<base href="/MWS_ENV/" />
<meta charset="utf-8"></meta>
	<link rel="stylesheet" href="" />
	<link rel="stylesheet" href="resources/base/css/MFSWeb.css" />
	
  	<script src="" type="text/javascript"></script>
  	<script src="resources/Env/js/envListing.js" type="text/javascript"></script>
</head>

Any ideas on what I have wrong?