Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
* Add usage information
* Add Maven coordinates
* Update build from source to include IntelliJ
  • Loading branch information
foo4u committed Feb 16, 2015
1 parent 1715bb6 commit 1d23ecf
Showing 1 changed file with 69 additions and 3 deletions.
72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,60 @@

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.

## Checkout and Build from Source
## Usage

### Add Spring MVC Cache Control as a dependency to your project.

#### Maven Projects

```
<dependency>
<groupId>net.rossillo.mvc.cache</groupId>
<artifactId>spring-mvc-cache-control</artifactId>
<version>1.1.0-RELEASE</version>
<scope>compile</scope>
</dependency>
```

#### Gradle Projects

```
compile 'net.rossillo.mvc.cache:spring-mvc-cache-control:1.1.0-RELEASE'
```

### Configuration

Simply include `net.rossillo.spring.web.mvc.CacheControlHandlerInterceptor` in your Spring MVC `-servlet.xml` file:

```
<mvc:interceptors>
<bean class="net.rossillo.spring.web.mvc.CacheControlHandlerInterceptor" />
</mvc:interceptors>
````
### Annotate Your Controllers
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:
```
@Controller
public final class DemoController {

/**
* Public home page, cacheable for 5 minutes.
*/
@CacheControl(maxAge = 300)
@RequestMapping({"/", "/home.do"})
public String handleHomePageRequest(Model model) {
...
}
}
```
See our [spring-mvc-cache-control-demo][demo] project for full details.
## Building from Source
1. Clone the repository from GitHub:
Expand All @@ -16,7 +69,14 @@ Spring MVC Cache Control is an extension to [Spring MVC][spring_mvc] that aims t
$ ./gradlew build
## Eclipse
## IDE Integration
### IntelliJ IDEA
IDEA 13+ natively support Gralde projects. Simply choose to import an existing project and select
the build.gradle file. Tick the checkbox to use the Gradle wrapper.
### Eclipse
To generate Eclipse metadata (.classpath and .project files), use the following Gradle task:
Expand All @@ -32,8 +92,14 @@ Use the following Gradle task to build the JavaDoc
$ ./gradlew javadoc
_Note: The result will be available in 'docs/build/api'._
_Note: The result will be available in 'spring-mvc-cache-control/build/docs/javadoc'._
## Contributing
Contributions are always welcome. Fork the repository, create a topic branch and send a pull request.
[spring_mvc]: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html
[gradle]: http://gradle.org/
[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
[status]: https://circleci.com/gh/foo4u/spring-mvc-cache-control.png?circle-token=2671c269c8ab085fb58617d58167ffe45bc70aac

0 comments on commit 1d23ecf

Please sign in to comment.