You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eugenebalt <eu...@yahoo.com> on 2011/08/24 18:32:28 UTC

Problem with setCacheable(false) (No-Cache Header in WebResource)

I have an issue with the setCacheable(false) header in a WebResource (Excel
file).

When the download link for the WebResource is clicked from a secure site
(SSL), there is an error: "Internet Explorer cannot find the site". I found
an explanation for this on MS's support site,
http://support.microsoft.com/kb/316431

"When Internet Explorer communicates with a secure Web site through SSL,
Internet Explorer enforces any no-cache request. If the header or headers
are present, Internet Explorer does not cache the file. Consequently, Office
cannot open the file. 

Web sites that want to allow this type of operation should remove the
no-cache header or headers. "


However if I remove setCacheable(false), I get a different issue: whenever I
try clicking the download link a 2nd or 3rd time, I get a "File Locked for
Editing" error even though I closed Excel properly on the 1st time. The 1st
time is fine, it opens the Excel file after the prompt without problems, but
any download of the same file after that, I get the "File Locked for
Editing" error and there is no other instance of Excel running, I exit Excel
normally after each download.

Maybe this isn't a Wicket issue, but an Excel issue, but I couldn't find any
explanation for why Excel would show a File Locked error when there is no
other instance of Excel running, and no one is holding a lock on the file.
Any ideas?

(Here, we are caching the file, it's coming from the local Temp Internet
Files folder. I removed the setCacheable(false) to get rid of the SSL
error.)

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3765955.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with setCacheable(false) (No-Cache Header in WebResource)

Posted by eugenebalt <eu...@yahoo.com>.
So to summarize:

1) When I do setCacheable(false), I can open my Excel link multiple times by
clicking the same link, no problems

2) When I do setCacheable(true), I get "File Locked" on my Excel any time
after the 1st download, and then I have to Delete Temporary Internet Files.
Once I delete my temp IE files, it's fine again, and I can download once
more, until I do it a second time, etc.

It looks like BOTH of these write a temp file into the temp IE directory.

But maybe the browser, or server, is still holding a lock in the 2nd case?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3766351.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with setCacheable(false) (No-Cache Header in WebResource)

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Aug 24, 2011 at 10:03 PM, eugenebalt <eu...@yahoo.com> wrote:
> Guys, what exactly happens when I do setCacheable(false) on a WebResource?
>
> Does that mean the downloaded file isn't cached locally? That can't be true,
> because I am getting a file called "report[1].xls" where the [1] indicates
> that it was saved in my Temp Internet Files folder, even when I do
> setCacheable(false).
the browser have to save it locally somewhere
to see whether it is cached or not just put a breakpoint in your code
and see whether there is a hit
>
> So what's the functionality of this command, with respect to files getting
> stored in the Temp Internet folder?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3766312.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with setCacheable(false) (No-Cache Header in WebResource)

Posted by eugenebalt <eu...@yahoo.com>.
Guys, what exactly happens when I do setCacheable(false) on a WebResource?

Does that mean the downloaded file isn't cached locally? That can't be true,
because I am getting a file called "report[1].xls" where the [1] indicates
that it was saved in my Temp Internet Files folder, even when I do
setCacheable(false).

So what's the functionality of this command, with respect to files getting
stored in the Temp Internet folder?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3766312.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with setCacheable(false) (No-Cache Header in WebResource)

Posted by eugenebalt <eu...@yahoo.com>.
Hi Angel, thanks for the reply. 

But it looks like this is not making it non-cacheable. It is cacheable, I
get the Excel prompt about reading the local file.

My new code with your suggestion:
----------------------------------

WebResource export = new WebResource() 
{
	@Override
	public IResourceStream getResourceStream() {
		ByteArrayResource bar = new ByteArrayResource("application/vnd.ms-excel",
createExcelBytes());
		return bar.getResourceStream();
	}

	@Override
	protected void setHeaders(WebResponse response) {
		super.setHeaders(response);
		response.setAttachmentHeader("report.xls");
		*response.setHeader("Cache-Control", "private"); *
	}
};
// COMMENTED OUT setCacheable(false)
//export.setCacheable(false);

ResourceLink exportLink = new ResourceLink("exportLink", export);	


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3768583.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Problem with setCacheable(false) (No-Cache Header in WebResource)

Posted by Ángel Luis Calvo Ortega <an...@cyum.es>.
The "Internet Explorer cannot find the site" is a bug of IE (until v8) 
that happens when it's tried to download a non-cacheable dynamic 
resource over SSL.
The solution is quite easy, don't use setCacheable(false). Instead set 
and only set the following attribute in the response:

response.setHeader("Cache-Control", "private");

This sets the resource non-cacheable and IE-friendly

Regards


El 24/08/2011 18:32, eugenebalt escribió:
> I have an issue with the setCacheable(false) header in a WebResource (Excel
> file).
>
> When the download link for the WebResource is clicked from a secure site
> (SSL), there is an error: "Internet Explorer cannot find the site". I found
> an explanation for this on MS's support site,
> http://support.microsoft.com/kb/316431
>
> "When Internet Explorer communicates with a secure Web site through SSL,
> Internet Explorer enforces any no-cache request. If the header or headers
> are present, Internet Explorer does not cache the file. Consequently, Office
> cannot open the file.
>
> Web sites that want to allow this type of operation should remove the
> no-cache header or headers. "
>
>
> However if I remove setCacheable(false), I get a different issue: whenever I
> try clicking the download link a 2nd or 3rd time, I get a "File Locked for
> Editing" error even though I closed Excel properly on the 1st time. The 1st
> time is fine, it opens the Excel file after the prompt without problems, but
> any download of the same file after that, I get the "File Locked for
> Editing" error and there is no other instance of Excel running, I exit Excel
> normally after each download.
>
> Maybe this isn't a Wicket issue, but an Excel issue, but I couldn't find any
> explanation for why Excel would show a File Locked error when there is no
> other instance of Excel running, and no one is holding a lock on the file.
> Any ideas?
>
> (Here, we are caching the file, it's coming from the local Temp Internet
> Files folder. I removed the setCacheable(false) to get rid of the SSL
> error.)
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-with-setCacheable-false-No-Cache-Header-in-WebResource-tp3765955p3765955.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org