Chapter 8. Optimizing Your Requests

In this chapter, we will be looking at different techniques to improve our application's performance.

We will implement classical ways of optimizing a web application: cache control headers, Gzipping, an application cache, and ETags, as well as more reactive stuff, such as asynchronous method calls and WebSockets.

A production profile

In the previous chapter, we saw how to define an application properties file that will only be read while launching the application with a specific profile. We will use the same approach and create an application-prod.properties file in src/main/resources, right next to the existing application.properties file. This way, we will be able to configure the production environment with optimized settings.

We will put a few properties in this file to get started. In Chapter 3, Handling Forms and Complex URL Mapping, we deactivated the Thymeleaf cache and forced translation bundles to reload on every access.

This is great for developing but is useless and time consuming in production. So let's fix that:

spring.thymeleaf.cache=true
spring.messages.cache-seconds=-1

A cache period of -1 means caching the bundle forever.

Now, if we launch our application with the "prod" profile, templates and bundles should be cached forever.

The properties coming from the "prod" profile will indeed overwrite the ones declared in our application.properties file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.117.212