Prevent caching AND have Option Explicit

C

Captain Nemo

If you look around on the web for advice on cache-control and using 'Option
Explicit' you get a paradox.

Both features are supposed to be the first piece of ASP code on the page.

Well they can't BOTH be first can they?

OK - I give up. How do you do it?
 
A

Aaron [SQL Server MVP]

A 20-second experiment with two pages would have yielded an answer faster
than it took you to type up your question.

Page 1:

<%
Option Explicit
Response.Expires = -1
%>

Page 2:

<%
Response.Expires = -1
Option Explicit
%>

I'll leave it, aptly, as an exercise to the reader to figure out which works
correctly, and which yields:

Microsoft VBScript compilation error '800a0400'
Expected statement
 
R

Ray Costanzo [MVP]

Without seeing the advice to which you're referring, I can only guess that
what the advice was. It was probably that Option Explicit should come first
in the code, and cache control is the first thing you should send to the
browser.

From the example here, http://www.aspfaq.com/show.asp?id=2022, you'd modify
it like so:

<%@ Language = VBScript %>
<%
Option Explicit
Dim pStr

pStr = "private, no-cache, must-revalidate"
Response.ExpiresAbsolute = #2000-01-01#
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", pStr
%>
 
C

Captain Nemo

Aaron said:
A 20-second experiment with two pages would have yielded an answer faster
than it took you to type up your question.

Sorry, but I'm not an expert ASP programmer. In fact I'm not any kind of
ASP progammer. I'm a PHP programmer who's been saddled with the job of
debugging some idiot's ASP code that doesn't work properly and I have to
start somewhere.

Where I come from, we tend to respond to a straight question with a straight
answer.
 
A

Aaron [SQL Server MVP]

Where I come from, we tend to respond to a straight question with a
straight

Welcome to somewhere else, I guess. Notice I still provided all of the
information to give you an answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top