Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-21-2008, 01:52 PM
mihai11 mihai11 is offline
 
Join Date: Dec 2005
Location: Sibiu - Romania
Posts: 199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 04-21-2008, 07:04 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 
Reply With Quote
  #3  
Old 04-22-2008, 01:36 AM
mihai11 mihai11 is offline
 
Join Date: Dec 2005
Location: Sibiu - Romania
Posts: 199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MoT3rror View Post
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
Reply With Quote
  #4  
Old 04-22-2008, 02:18 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 04-22-2008, 03:01 AM
mihai11 mihai11 is offline
 
Join Date: Dec 2005
Location: Sibiu - Romania
Posts: 199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MoT3rror View Post
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 ....
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:37 PM.


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.04185 seconds
  • Memory Usage 2,211KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete