Problem solved!!!!!!! Everything was working ok with PHP. My class was working ok. The engineering and logic behind PHP was working. So... what was the problem? Apache... well, it wasn't a problem, but a misconfiguration or better said, a mis-optimization. In my first message, I stated: (quote) > there is no way I can send a 304 Not Modified header, when the data is > *over* ~100 bytes. > After 8 hours of working with this problem (which included sniffering and a lot of workarounds), and while I was smoking my final cigarrette before going to bed, I remembered that some time ago (well, some time like 2 years ago xD), I had enabled mod_disk_cache, with the following configuration: <IfModule mod_disk_cache.c> CacheRoot /tmp/apachecache/ CacheEnable disk / CacheDirLength 1 CacheDirLevels 5 CacheMaxFileSize 128000 *CacheMinFileSize 100* </IfModule> I commented that part, restarted Apache and bingo!!!! Instantly I had an 304 header. What do I think the problem was? Whenever Apache received a request, it handled it directly from _his_ cache and simply omitted what PHP was telling him to do. The weird thing was that the class entered the 304 header part, but Apache always ended up sending an 200 OK header and then the CSS. In first place it shouldn't have sended the CSS because when I entered the 304 part, it should have died. It simply couldn't send any other output. (And that was why I sniffered, if it shouldn't send the CSS; he must have been send some kind of error, but my surprise was really big when I saw that the raw data was just plain CSS, no other data was present). Why was Apache then sending a 304 whenever the data was under the 100 byte limit? Because he didn't have it in his cache and was obeying what PHP told him to do. (This configuration created a cache whenever the file size is between the 100 and 128000 bytes). Anyway... now I will be publishing the class soon on phpclasses.org under the BSD license. I'll work now on documentation and code cleanup but whenever it is ready I will leave the link in this same list (if it is allowed) xD Greetings, a lot of thanks to Richard for his code and Rene for his suggestion to take a look at Apache and good night :P (Despite being 7AM xD) On Wed, Jan 20, 2010 at 21:16, Camilo Sperberg <csperberg@xxxxxxxxxxxx>wrote: > > > On Wed, Jan 20, 2010 at 04:34, richard gray <rich@xxxxxxxxxxxx> wrote: > >> >> Camilo Sperberg wrote: >> >>> Hi list, my first message here :) >>> >>> To the point: I'm programming a class that takes several CSS files, >>> parses, >>> compresses and saves into a cache file. However, I would like to go a >>> step >>> further and also use the browser cache, handling the 304 and 200 header >>> types myself. >>> >>> Now, what is the problem? If I do it within a function, there is >>> absolutely >>> no problem, everything works like a charm. However, when I implement that >>> same concept into my class, there is no way I can send a 304 Not Modified >>> header, when the data is *over* ~100 bytes. >>> >>> >>> >> Hi Camilo >> >> For what it is worth I have implemented cacheing in a class and for me the >> 304 not modified header gets sent fine ... some example headers output is >> below together with the relevant code snippet.. >> >> // See if client sent a page modified header to see if we can >> // just send a not modified header instead >> if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && >> $_SERVER['HTTP_IF_MODIFIED_SINCE'] == self::$_gmmodtime) { >> >> header('HTTP/1.1 304 Not Modified'); >> return null; >> } >> >> if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && >> stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == self::$_etag) { >> >> header('HTTP/1.1 304 Not Modified'); >> return null; >> } >> >> >> HTTP/1.x 304 Not Modified >> Date: Wed, 20 Jan 2010 07:21:32 GMT >> Server: Apache/2.2.11 (Ubuntu) >> Connection: Keep-Alive >> Keep-Alive: timeout=5, max=1000 >> Etag: 444fbd9951f540ec1b6928db864c10dc >> Expires: Sun, 24 Jan 2010 06:16:06 GMT >> Cache-Control: public, must-revalidate >> Vary: Accept-Encoding >> >> I hope it helps.. >> >> Regards >> Rich >> > > I'll try this (and some other things I recently thought about) when I get > back home on friday :) I'll keep you updated. > > Thanks! > > > -- > Mailed by: > UnReAl4U - unreal4u > ICQ #: 54472056 > www1: http://www.chw.net/ > www2: http://unreal4u.com/ > -- Mailed by: UnReAl4U - unreal4u ICQ #: 54472056 www1: http://www.chw.net/ www2: http://unreal4u.com/