|
131 | 131 | useful for requests to fixed resources like images or stylesheets. An alternative may be to
|
132 | 132 | handle requests for such resources separately from the <code>XQueryUrlRewrite</code>
|
133 | 133 | servlet; this is discussed in <xref linkend="controller-mappings"/>.</para>
|
134 |
| - <programlisting language="xml"><ignore xmlns="http://exist.sourceforge.net/NS/exist"/></programlisting> |
| 134 | + <programlisting language="xml" xlink:href="listings/listing-14.xml"/> |
135 | 135 | <para>The <tag>ignore</tag> element may include an optional <link linkend="cache-control"><literal>cache-control</literal></link> element.</para>
|
136 | 136 | </sect2>
|
137 | 137 | <sect2 xml:id="redirect">
|
|
143 | 143 | request, and this can potentially trigger the controller again; care must be taken to avoid
|
144 | 144 | creaing an un-exitable loop.</para>
|
145 | 145 | <para>The URL to the <literal>redirect</literal> element is given in an attribute named <literal>url</literal>.</para>
|
146 |
| - <programlisting language="xml"><dispatch xmlns="http://exist.sourceforge.net/NS/exist"> |
147 |
| - <redirect url="..."/> |
148 |
| -</dispatch></programlisting> |
| 146 | + <programlisting language="xml" xlink:href="listings/listing-15.xml"/> |
149 | 147 | <para>A redirect will be visible to the user: for instance the user's web-browser will be
|
150 | 148 | updated to show the specified new URL.</para>
|
151 | 149 | </sect2>
|
|
205 | 203 | </listitem>
|
206 | 204 | </varlistentry>
|
207 | 205 | </variablelist>
|
208 |
| - <programlisting language="xml"><dispatch xmlns="http://exist.sourceforge.net/NS/exist"> |
209 |
| - <forward url="{$exist:controller}/modules/transform.xq"> |
210 |
| - <add-parameter name="doc" value="{$exist:resource}.xml"/> |
211 |
| - </forward> |
212 |
| -</dispatch></programlisting> |
| 206 | + <programlisting language="xml" xlink:href="listings/listing-16.xml"/> |
213 | 207 | <para>The <tag>forward</tag> element can contain the optional child elements: <link
|
214 | 208 | linkend="add-parameter"><literal>add-parameter</literal></link>, <link
|
215 | 209 | linkend="set-attribute"><literal>set-attribute</literal></link>, <link
|
|
230 | 224 | Parameter.</para>
|
231 | 225 | <para>The name of the parameter is taken from the <literal>name</literal> attribute, and the
|
232 | 226 | value from the <literal>value</literal> attribute.</para>
|
233 |
| - <programlisting language="xml"><add-parameter name="xxx" value="yyy"/></programlisting> |
| 227 | + <programlisting language="xml" xlink:href="listings/listing-17.xml"/> |
234 | 228 | <para>The original HTTP request will be copied before the change is applied. This applies only
|
235 | 229 | to the step on which it is placed, that is to say that subsequent steps in the pipeline will
|
236 | 230 | not see the parameter. </para>
|
|
242 | 236 | they and are not related to the HTTP Request or HTTP Response.</para>
|
243 | 237 | <para>The name of the request attribute is read from the <literal>name</literal> attribute,
|
244 | 238 | and the value from the <literal>value</literal> attribute.</para>
|
245 |
| - <programlisting language="xml"><set-attribute name="xxx" value="yyy"/></programlisting> |
| 239 | + <programlisting language="xml" xlink:href="listings/listing-18.xml"/> |
246 | 240 | <para>You can set arbitrary request attributes, for instance to pass information between
|
247 | 241 | XQuery modules. Some attribute names may be reserved by various servlets in the
|
248 | 242 | pipeline.</para>
|
|
251 | 245 | <para>The <tag>clear-attribute</tag> option clears a request attribute.</para>
|
252 | 246 | <para>The name of the request attribute is read from the <literal>name</literal>
|
253 | 247 | attribute.</para>
|
254 |
| - <programlisting language="xml"><clear-attribute name="xxx"/></programlisting> |
| 248 | + <programlisting language="xml" xlink:href="listings/listing-19.xml"/> |
255 | 249 | <para>Unlike parameters, request attributes will be visible to subsequent steps in the
|
256 | 250 | processing pipeline. They only need to be explicitly cleared once they are no longer needed
|
257 | 251 | by the user. eXist-db places no requirement on the user having to ever clear the
|
|
260 | 254 | <para>The <tag>set-header</tag> option sets an HTTP Response Header field.</para>
|
261 | 255 | <para>The name of the header is read from the <literal>name</literal> attribute, and the value
|
262 | 256 | from the <literal>value</literal> attribute.</para>
|
263 |
| - <programlisting language="xml"><set-header name="xxx" value="yyy"/></programlisting> |
| 257 | + <programlisting language="xml" xlink:href="listings/listing-20.xml"/> |
264 | 258 | <para>The HTTP response is shared between all steps in the pipeline, so all following steps will be able to see the change.</para></sect2>
|
265 | 259 | <sect2 xml:id="cache-control">
|
266 | 260 | <title>The <tag>cache-control</tag> Option</title>
|
|
270 | 264 | <para>Internally the URL Rewriting framework maintains a mapping between Input URLs and
|
271 | 265 | Dispatch Rules. When the cache is enabled, the <literal>controller.xq</literal> XQuery Main Module only needs to be
|
272 | 266 | executed once for each distinct input URL. Subsequent requests for the same URL will be served from the cache.</para>
|
273 |
| - <programlisting language="xml"><dispatch xmlns="http://exist.sourceforge.net/NS/exist"> |
274 |
| - <redirect url="..."/> |
275 |
| - <cache-control cache="yes"/> |
276 |
| -</dispatch></programlisting> |
| 267 | + <programlisting language="xml" xlink:href="listings/listing-21.xml"/> |
277 | 268 | <para>Note: only the URL rewrite rule is cached, the HTTP response itself is not cached! The <literal>cache-control</literal> setting is unrelated to any HTTP Cache Headers in the HTTP Response, and is unrelated to any client-side caching within a web-browser.</para>
|
278 | 269 | </sect2>
|
279 | 270 | </sect1>
|
|
0 commit comments