Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Need to add some custom php (setting cache headers) what is the best way?
Fifty
New
I need to set custom php headers to control caching, the quick & dirty way is to edit the main index.php. But that's probably not the proper way to do it
What is the easiest way, to add a little code snippet, without touching the core files? Do I need to create an Addon, or are there easier ways? I've used search, but couldn't find it (although I can hardly imagine that this hasn't been asked before, so perhaps I use the wrong keywords ...)
0
Comments
@Fifty
One solution would be to create a custom theme ( http://docs.vanillaforums.com/theming/quickstart/ )
and then edit the default.master file.
If it is a .tpl file, you would need to put the code in
<literal> </literal>
tags.editing index.php is the wrong way. The Gdn_Controller class sends its headers in the render() method. You can overwrite these headers via call to
Controller->setHeader($name, $value)
e.g. in a plugin viapublic function Base_render_before($sender) { $sender->setHeader(...); }
This might be of interest to you: https://github.com/vanilla/vanilla/pull/2948
Thanks @why606 and @mtschirs, I already have my own theme (primarily for the custom css) so I'm gonna test how that works with the php header setting!
You probably also want to do this for static files on your server, so I would rather do this in the server rules, e.g. in .htaccess:
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS