JAX-RS入门 十二: 可伸缩的JAX-RS应用
一、HTTP Caching
?
HTTP1.0中定义了Expires来指定cache在浏览器的生命时长。例如:
?
- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- ?

- @Path("/customers") ??public?class?CustomerResource?{ ?? ??????@Path("{id}") ?? ????@PUT?? ????@Consumes("application/xml") ?? ????public?Response?updateCustomer(@PathParam("id")?int?id, ?? ????????@Context?Request?request)?{ ?? ????????Customer?cust?=?findCustomer(id); ??????????EntityTag?tag?=?new?EntityTag( ?? ????????Integer.toString(cust.hashCode())); ??????????Date?timestamp?=?...;?//?get?the?timestampe ?? ????????ResponseBuilder?builder?= ??????????request.evaluatePreconditions(timestamp,?tag); ??????????if?(builder?!=?null)?{ ?? ????????????//?Preconditions?not?met! ?? ????????????return?builder.build(); ?? ????????} ??????????//...?perform?the?update?... ?? ????????builder?=?Response.noContent(); ??????????return?builder.build(); ?? ????} ??}??