SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot -rob-'s Avatar
    Join Date
    Mar 2003
    Location
    Earth
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing a header

    Simple question,

    Once you add an HTTP header, is there any way to remove or change it?
    Cheers,

    -rob-

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Could you explain why would want to do this or give an example, because perhaps you could arrange your code differently so the header isn't sent unless it's certain that it's required. As far as I know, you can't retract header information.

  3. #3
    SitePoint Zealot -rob-'s Avatar
    Join Date
    Mar 2003
    Location
    Earth
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. While I could re-arrange the code to only send the header under certain conditions, these conditions occur 99% of the time, so I was hoping to find a way to remove/change certain header information for the remaining 1%.

    Example
    --------
    Say for example you do not cache any pages by using the caching HTTP header in an include file as a header in the HTML code. You then have a page that has to use this header file, but you want to cache this page only.

    This is an example scenario of the type of thing I want to achieve.
    Cheers,

    -rob-

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't have Option Explicit switched on then simply add an If statement around the lines in your include file which set the header, like this:
    Code:
    If (Not CacheEnabled) Then
    Response.AddHeader "blah","blah"
    End If
    This way all your existing pages will operate as they always have without requiring any changes. Now in the single page that you DO want cached (i.e. that you DON'T want headers sent for), just put a "CacheEnabled = True" before the include. Job done.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •