An HTTP header passes information about requests by the browser and responses from the server. The information needed for the exchange to take place is included in the header without being displayed. The <cfheader> tag sets attribute/value pairs in the response header. The attributes of the tag are shown in Table 5.2.
A common use of the <cfheader> tag is to prevent a Web page from being cached by the browser. This caching can cause a problem if the Web page is used to display data that is being updated in some way. If database data is inserted, updated, or deleted, and the page to display that data is cached by the browser, the database records might not be shown accurately on the page. The Web browser has an EXPIRES attribute, which you can set to some time in the past so that the page will always be expired. The code to do so is as follows: <cfheader name="Expires" VALUE="#Now()#"> The entry created in the header would look something like this: Normal Expires: {ts '2006-01-01 19:34:42'} TIP If you run into a situation in which you need to prevent a page from being cached (for example, if proxy servers are being used), you must take into account different browsers and browser versions. The example shown here may not cover all possibilities. You might also want to test the following to be sure you get the best results for the range of browsers you are considering: <meta http-equiv="Pragma" content="No-Cache"> <meta http-equiv="Expires" content="0"> <cfheader name="Pragma" value="no-cache"> <cfheader name="cache-control" value="no-cache, no-store, must-revalidate"> |