Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined index: HTTP_ACCEPT_ENCODING

Tags:

php

apache

gzip

I use quickcache from http://sourceforge.net/projects/quickcache to have some dynamic pages cached for some time

In my server [HTTP_ACCEPT_ENCODING] => gzip, deflate

but from quickcache_main.php

if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"],'x-gzip') !== false) 

and

if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"],'gzip') !== false) {

is invoked I get the title error in error_log. I don't see any problem loading those cached pages from a mysql table or accessing a not cached (or expired) page when the scripts creates the new cached one. I also never saw my tests triggered a new error log like the title. Anyway I see them very frequently listed. What I am missing?

like image 557
dstonek Avatar asked Dec 11 '25 12:12

dstonek


1 Answers

Change your code to:

if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
    ob_start();            
}
elseif (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') == false) {
    if (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') == false) {
        ob_start();
    }
    elseif(!ob_start("ob_gzhandler")) {
        ob_start();
    }   
}
elseif(!ob_start("ob_gzhandler")) {
    ob_start();
}
like image 72
Alexander Savin Avatar answered Dec 14 '25 08:12

Alexander Savin