Skip to content

Commit 1d23ecf

Browse files
committed
Update README
* Add usage information * Add Maven coordinates * Update build from source to include IntelliJ
1 parent 1715bb6 commit 1d23ecf

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

README.md

+69-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,60 @@
22

33
Spring MVC Cache Control is an extension to [Spring MVC][spring_mvc] that aims to simplify implementing HTTP/1.1 Cache-Control headers for annotated MVC controllers.
44

5-
## Checkout and Build from Source
5+
## Usage
6+
7+
### Add Spring MVC Cache Control as a dependency to your project.
8+
9+
#### Maven Projects
10+
11+
```
12+
<dependency>
13+
<groupId>net.rossillo.mvc.cache</groupId>
14+
<artifactId>spring-mvc-cache-control</artifactId>
15+
<version>1.1.0-RELEASE</version>
16+
<scope>compile</scope>
17+
</dependency>
18+
```
19+
20+
#### Gradle Projects
21+
22+
```
23+
compile 'net.rossillo.mvc.cache:spring-mvc-cache-control:1.1.0-RELEASE'
24+
```
25+
26+
### Configuration
27+
28+
Simply include `net.rossillo.spring.web.mvc.CacheControlHandlerInterceptor` in your Spring MVC `-servlet.xml` file:
29+
30+
```
31+
<mvc:interceptors>
32+
<bean class="net.rossillo.spring.web.mvc.CacheControlHandlerInterceptor" />
33+
</mvc:interceptors>
34+
````
35+
36+
### Annotate Your Controllers
37+
38+
Use the `@CacheControl` annoation on either (or both) type level `@Controller`s or method level `@RequestMapping`s. The handler interceptor will read the annotations and generate HTTP/1.1 complaint cache-control headers. For example:
39+
40+
```
41+
@Controller
42+
public final class DemoController {
43+
44+
/**
45+
* Public home page, cacheable for 5 minutes.
46+
*/
47+
@CacheControl(maxAge = 300)
48+
@RequestMapping({"/", "/home.do"})
49+
public String handleHomePageRequest(Model model) {
50+
...
51+
}
52+
}
53+
```
54+
55+
See our [spring-mvc-cache-control-demo][demo] project for full details.
56+
57+
58+
## Building from Source
659
760
1. Clone the repository from GitHub:
861
@@ -16,7 +69,14 @@ Spring MVC Cache Control is an extension to [Spring MVC][spring_mvc] that aims t
1669
1770
$ ./gradlew build
1871
19-
## Eclipse
72+
## IDE Integration
73+
74+
### IntelliJ IDEA
75+
76+
IDEA 13+ natively support Gralde projects. Simply choose to import an existing project and select
77+
the build.gradle file. Tick the checkbox to use the Gradle wrapper.
78+
79+
### Eclipse
2080
2181
To generate Eclipse metadata (.classpath and .project files), use the following Gradle task:
2282
@@ -32,8 +92,14 @@ Use the following Gradle task to build the JavaDoc
3292
3393
$ ./gradlew javadoc
3494
35-
_Note: The result will be available in 'docs/build/api'._
95+
_Note: The result will be available in 'spring-mvc-cache-control/build/docs/javadoc'._
96+
97+
## Contributing
98+
99+
Contributions are always welcome. Fork the repository, create a topic branch and send a pull request.
100+
36101
37102
[spring_mvc]: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html
38103
[gradle]: http://gradle.org/
104+
[demo]: https://github.com/foo4u/spring-mvc-cache-control/blob/master/spring-mvc-cache-control-demo/src/main/java/net/rossillo/spring/web/mvc/demo/DemoController.java
39105
[status]: https://circleci.com/gh/foo4u/spring-mvc-cache-control.png?circle-token=2671c269c8ab085fb58617d58167ffe45bc70aac

0 commit comments

Comments
 (0)