vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Can I enable the no-cache headers only for some custom script ? (https://vborg.vbsupport.ru/showthread.php?t=176780)

mihai11 04-21-2008 12:52 PM

Can I enable the no-cache headers only for some custom script ?
 
Hi,

I know that there is an option to globally enable no-cache headers (at PHP level, not from the META tags) in the admin CP, but this option enables the no-cache headers for the entire forum. Is it possible to programatically enable the no-cache headers for a custom page ?

Regards,
Razvan

MoT3rror 04-21-2008 06:04 PM

This is the headers for no-cache but I wouldn't run them in a plugin or anything because vBulletin may already send them.
PHP Code:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past 


mihai11 04-22-2008 12:36 AM

Quote:

Originally Posted by MoT3rror (Post 1496054)
This is the headers for no-cache but I wouldn't run them in a plugin or anything because vBulletin may already send them.
PHP Code:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past 


I completely agree with you, this is why I don't want to send the headers myself, I want to change the VB option for a custom page so that the VB system will send the headers for me.

I am thinking that the option of sending or not the "no-cache" headers should be just an option in an array - like in this array:

$vbulletin->options['bburl']

instead of "bburl" it should be something like "nocache". If I set it to true:

$vbulletin->options['nocache'] = true;

then the VB system should send the no-cache headers.

What do you think ? Is the system working like this ? I am going to check the "options" array tomorrow.

The advantage of using the above system is that the headers will NOT be sent twice if they are enabled globally for the whole board.



Regards,
Razvan

MoT3rror 04-22-2008 01:18 AM

The headers are sent in a function called exec_headers(). This function is called in the global.php.
Line 91 in 3.7 R3
Line 85 in 3.6.8 PL2

I couldn't find any hook that is called after the options are pulled out or before exec_headers is called. So you can either put
PHP Code:

$vbulletin->options['nocacheheaders'] = true

Or you can modify the exec_headers function to do it per page.

mihai11 04-22-2008 02:01 AM

Quote:

Originally Posted by MoT3rror (Post 1496282)
The headers are sent in a function called exec_headers(). This function is called in the global.php.
Line 91 in 3.7 R3
Line 85 in 3.6.8 PL2

I couldn't find any hook that is called after the options are pulled out or before exec_headers is called. So you can either put
PHP Code:

$vbulletin->options['nocacheheaders'] = true

Or you can modify the exec_headers function to do it per page.

Great ! I just tested this in IE, FF, Safari and Opera on Windows and FF and Opera on Ubuntu and it works ! You don't need to modify any function, all you need to do is to set this:

PHP Code:

$vbulletin->options['nocacheheaders'] = true

before calling global.php. This is exactly what I was looking for !

Originally, I was thinking to visualize the headers that I got from the server (there is a hack for FF that allows you to do that), but I don't think that I need to install that hack any more. Since this is working in all major browsers, that means that the correct headers are sent !

It is wrong what I did above !!!

Before calling global.php, the array "$vbulletin->options" is not defined !

I don't know why it worked on a given page. Anyway, what I decided to do in the end is this:

PHP Code:

if ($vbulletin->options['nocacheheaders'] == 0)
{
    
// send the no-cache headers !
    
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past


In other words, if the nocache headers were not already sent, then send them. I hope I didn't do any stupid mistakes this time ....


All times are GMT. The time now is 06:23 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01503 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete