| By Bruce Van Horn | Article Rating: |
|
| March 11, 2002 12:00 AM EST | Reads: |
9,759 |
Sometimes I take for granted just how cool ColdFusion really is! The other day one of my programmers asked me how to do what I thought was a fairly easy task.
When I showed him the four lines of CF code he needed, he said, "ColdFusion rocks! It would have taken me 50 lines in PHP to do the same thing!" What could I say, other than "Yep"? Below are a few lines of code that I hope will make your life easier.
Q:How can we prevent a browser from caching the content of our Web pages? For example, our content is constantly changing; if a user browses a page, goes on to other pages, and then uses the back button to return to a previous page, we don't want the user seeing the same content he or she saw the first time - we want the user to see the updated content on that page. Can we do this?
A:Absolutely! Most browsers do cache page content to enhance the performance of site navigation. However, you can put some code into your pages that will instruct the browser not to cache their content. Unfortunately, different browsers require different no-cache parameters, so I use three tags to make sure it works in all browser versions. Place the following code at the top of each page you don't want cached:
<CFHEADER NAME="Expires"
VALUE="#Now()#">
<CFHEADER NAME="Pragma"
VALUE="no-cache">
<CFHEADER NAME="cache-control"
VALUE="no-cache, no-store,
must-revalidate">
Q:Our application needs to send out an e-mail message on behalf of our users; however, our mail server doesn't allow relaying from e-mail addresses outside our domain. We want the message to come from one of our e-mail accounts, but have a reply-to set to the address of the user who sent the message. I don't see any way for CFMAIL to set a "Reply-To" attribute. Can this be done?
A:This is a great question! Yes, it can be done now that CFMAIL can use the CFMAILPARAM tag. You may be aware that you can use the CF-MAILPARAM tag to send multiple file attachments, but you can also use it to send mail header information (like "Reply-To"). Here's all you have to do:
<cfmail to="paul@domain.com"Q:Is there a way to program ColdFusion to restart after so many database connection errors? And, more generally, is there a way of programmatically restarting ColdFusion?
from="noreply@abcgreet
ings.com"
subject="You have received a Birthday Greeting!">
<cfmailparam name="Reply-To"
value="yourfriend@somedomain.com">
Message body goes here...
</cfmail>
A:Yes and no. Yes in the CF Administrator - you can have CF restart after a certain number of failed requests (page or DB requests). You can get it to restart by checking the "Timeout requests after ___ seconds" box in the Settings section (be sure to set a timeout in seconds - do not leave it set to 0). Also check the "Restart at ___ unresponsive requests" box and plug in a number. Don't set either of these settings too low or CF will be restarting all the time.
There is no CF tag or function to restart the CF service, but you can write a .bat file to issue an NT command to stop or start the service:
net stop "World Wide Weband then call that .bat file using CFEXECUTE:
Publishing Service"
net stop "Cold Fusion
Executive"
net stop "Cold Fusion RDS"
net stop "Cold Fusion
Application Server"
net start "Cold Fusion
Application Server"
net start "Cold Fusion RDS"
net start "Cold Fusion Executive"
net start "World Wide Web
Publishing Service"
<!--- build a form that has a submit button on it and points to this action page --->
<cfif isDefined("Form.restart")>
<cfexecute
NAME="C:\websrvr\htdocs\restart
svcs.bat"/>
All webservices (IIS & CF)
will be restarted. Please
check back in 30 seconds.
</cfif>
Please send your questions about ColdFusion (CFML, CF Server, or CF Studio) to AskCFDJ@sys-con.com. Visit our archive site at www.netsitedynamics.com/AskCFDJ.
Published March 11, 2002 Reads 9,759
Copyright © 2002 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Bruce Van Horn
Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.
![]() |
Drew 11/16/07 04:41:05 AM EST | |||
Has anyone actually tried that cf restart method? I've found that when you cfexecute a .bat or .cmd as soon as the CF service stops the script is also terminated and cf doesn't actually get started again. |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Reader Sued
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Adobe Betas Target RIAs and Cloud Computing
- Adobe MAX 2009 Online
- Thinking of Flex in London
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe & Salesforce Cut Cloud Deal
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Is Microsoft as Free as Open Source?
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- Adobe Flex Developer Earns $100K in New York City
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





































