{#========================================== Spincast HTTP Caching plugin ==========================================#} {% extends "../../layout.html" %} {% block sectionClasses %}plugins hasBreadCrumb plugins-spincast-http-caching{% endblock %} {% block meta_title %}Plugins - Spincast HTTP Caching{% endblock %} {% block meta_description %}Spincast HTTP Caching plugin : ETag, Cache-Control, etc.{% endblock %} {% block scripts %} {% endblock %} {% block body %}
This plugin provides an implementation for the Request Context add-on CacheHeadersRequestContextAddon interface : SpincastCacheHeadersRequestContextAddon
Have a look at the
HTTP caching section of the
documentation for all the information about this topic.
.cacheHeaders() add-on from a Route Handler
to set some cache headers :
public void myHandler(AppRequestContext context) {
// Sends "Cache-Control" header
context.cacheHeaders().cache(60);
}
If you use the spincast-default artifact, this plugin is already installed so
you have nothing more to do!
If you start from scratch using the spincast-core artifact, you can use the
plugin by adding this artifact to your project:
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-plugins-http-caching</artifactId>
<version>{{spincast.spincastCurrrentVersion}}</version>
</dependency>
You then install the plugin's Guice module, by passing it to the Guice.createInjector(...) method:
Injector guice = Guice.createInjector(
new SpincastCoreGuiceModule(args),
new SpincastHttpCachingPluginGuiceModule(AppRequestContext.class,
AppWebsocketContext.class)
// other modules...
);
... or by using the install(...) method from your custom Guice module:
public class AppModule extends SpincastCoreGuiceModule {
@Override
protected void configure() {
super.configure();
install(new SpincastHttpCachingPluginGuiceModule(getRequestContextType(),
getWebsocketContextType()));
// other modules...
}
// ...
}