Adding Cache-control settings to HTTP-header using Jetty web server
Symptoms
The Expires-directive in the HTTP-header is automatically added to all VoiceXML pages generated by VoiceObjects Server. This cannot be modified. The directive remains:
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Some speech platforms require additional information in the HTTP-Header in order to ensure correct communication with VoiceObjects Server (e.g. prevent caching of VoiceXML-pages).
This article explains how to add those HTTP directives if using Jetty as web server.
Resolution
Adding HTTP-Header elements can be achieved by adding following XML-elements to the respective Jetty configuration file for VoiceObjects Server (?/WEB-INF/etc/Jetty5/VOServer.xml).
For example if you want to add the HTTP-Header element
- Cache-Control: no-cache
for all VXML pages sent by VoiceObjects Server follow these steps:
- Create a backup copy of the VOServer.xml
- Open the file and search for:
<Call name="addWebApplication">
<Arg>/VoiceObjects</Arg>
<Arg><!-- VoiceObjects Installation directory --></Arg>
</Call>
- Add the following section
<Call name="addWebApplication">
<Arg>/VoiceObjects</Arg>
<Arg><!-- VoiceObjects Installation directory --></Arg>
<Call name="addHandler">
<Arg>
<New class="org.mortbay.http.handler.SetResponseHeadersHandler">
<Call name="setHeaderValue">
<Arg type="String">Cache-Control</Arg>
<Arg>no-cache</Arg>
</Call>
</New>
</Arg>
</Call>
</Call>
- Save the file and restart the server.
For convenience you can also easily add the same directive with multiple values using the <Array>-element: Lets take e.g.
Cache-Control: no-cache Cache-Control: public
will be produced by the following block:
<Call name="addWebApplication">
<Arg>/VoiceObjects</Arg>
<Arg><!-- VoiceObjects Installation directory --></Arg>
<Arg>
<New class="org.mortbay.http.handler.SetResponseHeadersHandler">
<Call name="setHeaderValues">
<Arg type="String">Cache-Control</Arg>
<Arg>
<Array type="java.lang.String">
<Item>no-cache</Item>
<Item>public</Item>
</Array>
</Arg>
</Call>
</New>
</Arg>
</Call>
Further information
For further information refer to