Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Google Page Speed - "Leverage Proxy Caching" #6

Striker21 opened this Issue May 30, 2010 · 1 comment


None yet
2 participants

Google Page Speed recommends adding a Cache-Control:private setting to static files like .js and .css while adding a Cache-Control:public setting to images. I implemented a quick fix for it that lets you configure what file types receive the private heading and defaults all others to public. I honestly don't have a clue how to work GitHub, so I'll just paste what I did.

Under config.php I added this at the bottom:

//Specify which file types will receive a "Cache-Control: private" header. All other types will be set to public

$settings['cachePrivate'] = array('js','css');

Then added this before "echo $content" near line 195 under index.php

if(in_array($fileType, $settings['cachePrivate']))
header('Cache-Control: private');
else header('Cache-Control: public');

And added this final part in before the "readfile($cachedFile)" at the very bottom.

$parts = explode(".",$cachedFile);

$fileType = $parts[count($parts)-2];

if(in_array($fileType, $settings['cachePrivate']))
header('Cache-Control: private');
else header('Cache-Control: public');

My line numbers may be off a bit but I'm sure you get the idea. I'm also sure there's a more efficient way to do this, but I was in a hurry.

vladfr commented Nov 9, 2010

This should be pulled, sounds nice!
Also, another tip for proxy caching is to not use ? in the URLs you want to be cached.
I know the .htaccess file does this, but maybe a line in the docs would help, seeing as you have to edit the path to SmartOptimizer inside said .htaccess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment