$Web Expire: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Web_Expire}}
{{DISPLAYTITLE:$Web_Expire}}
<span class="pageSubtitle"><section begin="desc" />Set expiration date/time of Web response<section end="desc" /></span>
<span class="pageSubtitle">Set expiration date/time of Web response</span>




Line 8: Line 8:


==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /><span class="term">%rc</span> = $Web_Expire( exp_time )
<p class="syntax"><span class="term">%rc</span> = <span class="literal">$Web_Expire</span>(<span class="term"> exp_time</span> )
<section end="syntax" /></p>
</p>


===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>exp_time</th>
<tr><th>exp_time</th>
<td>A date/time expressed in seconds since 12 AM on January 1, 1900. You can use the <var>[[$Web_Datens]]</var> function to get the current date in this format, and manipulate it using standard <var class="product">User Language</var> expressions.
<td>A date/time expressed in seconds since 12 AM on January 1, 1900. You can use the <var>[[$Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS|$Web_DateNS]]</var> function to get the current date in this format, and manipulate it using standard <var class="product">SOUL</var> expressions.
</td></tr></table>
</td></tr></table>


===Return codes===
===Return codes===
<table class="syntaxTable">
<table class="thJustBold">
<tr><th>Code</th>
<tr class="head"><th>Code</th>
<th>Meaning</th></tr>
<th>Meaning</th></tr>
<tr><th>0</th>
<tr><th>0</th>
<td>Completed successfully</td></tr>
<td>Completed successfully</td></tr>
<tr><th>-1</th>
<tr><th>-1</th>
<td>Not a web thread</td></tr>
<td>Not a web thread</td></tr>
<tr><th>-4</th>
<tr><th>-4</th>
<td>Invalid datetime value</td></tr>
<td>Invalid datetime value</td></tr>
</table>
</table>


==Examples==
==Examples==
Use <var>$Web_Expire</var> to control how long a browser caches an entity returned by your application.
Use <var>$Web_Expire</var> to control how long a browser caches an entity returned by your application.
<p class="code"> * Get current date in binary
<p class="code">* Get current date in binary  
%x = $Web_DateNS
%X = $WEB_DATENS
&#42; Add one week to the current date
%x = %x + 7*24*60*60
* Add one week to the current date
&#42; Ensure browser doesn't cache returned data
&#42; longer than one week  
%X = %X + 7*24*60*60
%rc = $Web_Expire( %x )  
&#42; Changed my mind, only cache URL for 1 hour.
* Ensure browser doesn't cache returned data
&#42; The previous <var>$Web_Expire</var> call is forgotten.
* longer than one week
%x = %x - (7*24-1)*60*60
%rc = $Web_Expire( %x )
%RC = $Web_Expire( %X )
* Changed my mind, only cache URL for 1 hour.
* The previous <var>$Web_Expire</var> call is forgotten.
%X = %X - (7*24-1)*60*60
%RC = $Web_Expire( %X )
</p>
</p>


In the above example, <var>$Web_Expire</var> is called to set the expiration date for the response entity. A second <var>$Web_Expire</var> demonstrates that you can override the <var>$Web_Expire</var> value any time you wish.  
In the above example, <var>$Web_Expire</var> is called to set the expiration date for the response entity. A second <var>$Web_Expire</var> demonstrates that you can override the <var>$Web_Expire</var> value any time you want.  


==See also==  
==See also==  
<ul>
<ul>
<li><var>[[$Web_Last_Modified]]</var>
<li><var>[[$Web_Last_Modified]]</var>
<li>[[Janus Web Server application coding considerations#Understanding browser caching|"Understanding browser caching"]]
<li>[[Janus Web Server application coding considerations#Understanding browser caching|Understanding browser caching]]
</ul>
</ul>


[[Category:Janus Web Server $functions|$Web_Expire]]
[[Category:Janus Web Server $functions|$Web_Expire]]

Latest revision as of 20:25, 2 September 2014

Set expiration date/time of Web response


$Web_Expire sets the expiration date and time for the Web Server response entity being returned by the application. Using $Web_Expire, you can control how long a browser caches an entity returned by your application.

$Web_Expire requires one argument and returns a numeric status code. It is also callable.

Syntax

%rc = $Web_Expire( exp_time )

Syntax terms

exp_time A date/time expressed in seconds since 12 AM on January 1, 1900. You can use the $Web_DateNS function to get the current date in this format, and manipulate it using standard SOUL expressions.

Return codes

Code Meaning
0 Completed successfully
-1 Not a web thread
-4 Invalid datetime value

Examples

Use $Web_Expire to control how long a browser caches an entity returned by your application.

* Get current date in binary %x = $Web_DateNS * Add one week to the current date %x = %x + 7*24*60*60 * Ensure browser doesn't cache returned data * longer than one week %rc = $Web_Expire( %x ) * Changed my mind, only cache URL for 1 hour. * The previous $Web_Expire call is forgotten. %x = %x - (7*24-1)*60*60 %rc = $Web_Expire( %x )

In the above example, $Web_Expire is called to set the expiration date for the response entity. A second $Web_Expire demonstrates that you can override the $Web_Expire value any time you want.

See also