Commits

Justin Sheehy committed 9dc315d

Automated commit message

Comments (0)

Files changed (1)

ExampleResources.wiki

 </body></html>
 }}}
 
-HTTP caching support is also quite easy, with functions allowing resources to define {{{ last_modified }}} , {{{ expires }}}, and {{{ generate_etag }}}. For instance, since representations of this resource vary only by URI Path, I could use an extremely simple entity tag unfit for most real applications but sufficient for this example:
+HTTP caching support is also quite easy, with functions allowing resources to define (e.g.) {{{ last_modified }}} , {{{ expires }}}, and {{{ generate_etag.}}} For instance, since representations of this resource vary only by URI Path, I could use an extremely simple entity tag unfit for most real applications but sufficient for this example:
 
 {{{
 #!erlang
-generate_etag(ReqData, Context) ->
-    {ReqData#wm_reqdata.path, ReqData, Context}.
+generate_etag(ReqData, Context) -> {wrq:raw_path(ReqData), ReqData, Context}.
 }}}
 
-And now the response from our earlier request is appropriately entity-tagged:
+Similarly, here's a trivial expires rule:
+
+{{{
+#!erlang
+expires(ReqData, Context) -> {{{2021,1,1},{0,0,0}}, ReqData, Context}.
+}}}
+
+And now the response from our earlier request is appropriately tagged:
 
 {{{
 HTTP/1.1 200 OK
 Vary: Accept
-Server: MochiWeb/1.1 WebMachine/0.12 (A Very Small Sandwich)
-ETag: a/resource/path
-Date: Tue, 23 Sep 2008 01:30:20 GMT
-Content-Type: text/plain
-Content-Length: 29
+Server: MochiWeb/1.1 WebMachine/0.97
+Expires: Fri, 01 Jan 2021 00:00:00 GMT
+ETag: /demo/authdemo
+Date: Sun, 15 Mar 2009 02:59:02 GMT
+Content-Type: text/html
+Content-Length: 59
+
+<html><body>Hello authdemo from webmachine.
+</body></html>
 }}}
 
 For more details, read the source of the resources linked at the top of this page.