Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Tag blues, html2excel and html2word

Status
Not open for further replies.

pixiesfb

Programmer
Apr 27, 2001
62
US
I got the html2excel and cf_html2word custom tags at

They work well on first use, but after that the resulting .xls or .doc is cached. Unless you close your browser and re-open, you will never get a fresh list. Is there any way to fix these so I don't have to close and re-open the browser?

Thanks.
 
hi pixiesfb

Try this:

<CFHEADER name=&quot;pragma&quot; value=&quot;no-cache&quot;>

I believe that this will do the trick.

 
Thanks, I'll try it tomorrow and let ya know how it works.
 
Hmmm, I can't seem to get this to work.
I also tried

<CFHEADER Name=&quot;Expires&quot; Value=&quot;#Now()#&quot;>
<CFHEADER NAME=&quot;cache-control&quot; VALUE=&quot;no-cache, no-store, must-revalidate&quot;>

and

<cfheader name=&quot;pragma&quot; value=&quot;no-cache&quot;>
<cfheader name=&quot;expires&quot; value=&quot;0&quot;>

and

<cfheader name=&quot;expires&quot; value=&quot;#Now()#&quot;>
<cfheader name=&quot;pragma&quot; value=&quot;no-cache&quot;>

also tried

Cachedwithin=&quot;#createTimeSpan(&quot;0&quot;,&quot;0&quot;,&quot;5&quot;,&quot;0&quot;)#&quot; in the cfquery tag.

I've tried hard-coding my select statement to try and get different results, but that is not where the problem is.

Any advice would be appreciated!

 
Now that im re-reading your original message im realizing the problem is not the CFM page that is returning content to the client. The issue is temp files.

If you have a spreadsheet for July 17, 2001, and the URL to pull this up was

XCEL.cfm?ID=071701

.. a temp file is generated with that URL as part of its name. The CFM template will continue to generate dynamic results, and a brand new XCEL file on the server, but the browser will never want a new one since it already has one.

Just to check this, check the XCEL file that is stored on the server... open it directly, check the values, close it, and then run the CFM page again. When the file is over writted by CF_HTML2Excel open the XCEL file again and see if its new.

My guess is the server's file will continue to be dynamic, but the client's cache will only request a new file after the temp has been removed (after closing the window).

: / lets give that a shot, let me know what you find
 
OK, I have the beginnings of a solution here, with an obvious problem.

I set a session variable to get a number 1,2,3,4,5, or 6:

<cfset session.currentsecond=&quot;#left(Second(Now()), 1)#&quot;>

I name the output file:

filename=&quot;MyExcelList#session.currentsecond#&quot;

So I will eventually have files named:

MyExcelList1
MyExcelList2
MyExcelList3
MyExcelList4
MyExcelList5
MyExcelList6.


They will be deleted with a cffile delete right before creating a new page.

Here is the obvious problem: If the client creates a page at 20 seconds and at 28 seconds, (for example), I will not get a fresh page.

I don't want to have hundreds of files to ensure randomness.

Anyway, I'm sure I'm being a bone-head. Thanks for suggestions!
 
Its ok, im blonde and sometimes you just have to go for it. Heheh, no thats not a bad solution... but you see the URL still determines the client side caching of the XCEL doc, so creating multiple unique files on the server isn't going to help.

I thought on this last night and did some reading so as to have a fresh suggestion this morning, but im still blank. Best thing I can think of is make the user download the XLS file instead of opening in the browser... but of course thats not a solution its a change to the scope of the project.

: / good luck
 
Eureka!!!!!!

Here is what I did...

<!-------Delete any old Temporary Files------->

<cfset session.currenttime=&quot;#TimeFormat(Now(), &quot;HHMMSS&quot;)#&quot;>

<cfparam name=&quot;Attributes.GetDirectory&quot; default=&quot;#GetDirectoryFromPath(GetTemplatePath())#&quot;>
<cfset DeletePath = Attributes.GetDirectory&&quot;BlankExcel&quot;>

<cfdirectory action=&quot;LIST&quot; directory=&quot;#DeletePath#&quot; name=&quot;DeleteFromFolder&quot;>

<cfloop query=&quot;DeleteFromFolder&quot;>
<cfoutput>

<cfset xname=&quot;#Lcase(name)#&quot;>

<cftry>
<cffile action=&quot;DELETE&quot; file=&quot;#DeletePath#\#xname#&quot;>
<cfcatch type=&quot;Any&quot;>
</cfcatch>
</cftry>
</cfoutput>
</cfloop>

Then, when the html2excel custom tag is called, I use some code to delete the temp file as soon as I close the window. (It's too much code to put here, download the tag and check it out if you are curious:
So I guess I'm deleteing the files from &quot;both ends&quot; if people are opening it on different computers, (something like that??).

Anyway, it appears to be working very well.

(Multipe unique filename DO deterimine client side caching!)

Thanks for the help everyone,

-Pixies
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top