Welcome Guest, Not a member yet? Register   Sign In
Cache javascript/css?
#1

[eluser]Tweakin[/eluser]
I'm a big fan of including just one large file for js or css on my sites to save on page load. I usually have several separate files of each (easier to work with) then add them together through the magic of whatever server-side language I am using and outputting them in one compact chunk.

So I'm starting my first major CI project and am just adding this functionality in now. I have a controller (Assets) with two functions (js and css) that compact and combine each respective set of files, then output them with the appropriate Content-type. This works as expected but I usually like to add a cache into the mix to save server load on compacting/combining for each page hit.

I would like to use CI's built in cache functionality for this but am not sure it will work. It seems to return all cache files as type text/html, destroying my text/css or text/javascript set in the actual controller.

Has anyone worked around a similar issue to this? It would be easy enough to make my own cache for this, but I'd rather make use of the already existing cache in CI.
#2

[eluser]Devon Lambert[/eluser]
Can't say I have a specific answer for you... other than to check out carabiner.

Hope it helps. :-)
#3

[eluser]n0xie[/eluser]
Afaik the output caching function in CI is only meant to cache complete output (basically rendered (X)HTML), which would explain why it sets the headers incorrect. You could overwrite this behaviour by extending the output class or if you want partial caching there are several options available (MP_Cache comes to mind as well as well as Phil Sturgeon's Caching library).
#4

[eluser]tarciozemel[/eluser]
In fact, you don't got a better performance doing this... Take a look at Head JS.

Regards!




Theme © iAndrew 2016 - Forum software by © MyBB