Caching and headers |
[eluser]Aquillyne[/eluser]
Any hope of a future update to the CI core that just works headers into the caching by default? ![]()
[eluser]Aquillyne[/eluser]
Okay I've been looking over the code and here's what I think. I don't need to go as far as the Suffix extension. I just want to cache headers. I'd need to extend the Output class. But, looking at the code, I'd have to extend a huge amount (which I'm never fond of, because it doesn't make you update-proof). On top of it, I'd be extending a huge amount of code just to access 10 or so lines in 2 functions. So the Suffix extension is too much, and extending the Output class is too ugly. The solution? The CI code for the Output class actually reads: Code: /** Yes, even the developers admit this limitation. The solution: shout loud enough for the developers to hear! The Suffix extension proved that it's not hard to cache headers. CI is also storing the time-stamp inside the file. Just store the headers there too. It takes 10 lines of code. Please, someone get this to a developer's eye and beg them to work it into the next CI update. It will save me so much trouble, it would make CI better, and it would allow them to remove that embarassing comment... :cheese:
[eluser]Colin Williams[/eluser]
Quote:Please, someone get this to a developer’s eye and beg them to work it into the next CI update. It will save me so much trouble, it would make CI better, and it would allow them to remove that embarassing comment… Fix it and commit it back to the community. C'mon now.
[eluser]Aquillyne[/eluser]
[quote author="Colin Williams" date="1216632635"]Fix it and commit it back to the community. C'mon now.[/quote] How? I can do that? Where huh?
[eluser]Colin Williams[/eluser]
Like, how do you fix it, can you fix it, and where do your fix it? Or, how do you commit it, can you commit it, and where do your commit it? For the latter, the Wiki is a nice place to start, but it might serve the community better to house and document it on your own site with a link to it from the Wiki.
[eluser]Aquillyne[/eluser]
[quote author="Colin Williams" date="1216637532"]For the latter, the Wiki is a nice place to start, but it might serve the community better to house and document it on your own site with a link to it from the Wiki.[/quote] The latter. But that's just publishing a hack. And hacks are ugly. How can I get my little addition into a core CI release? It's just 10 pretty cool lines...
[eluser]Derek Allard[/eluser]
Post your code please. In order for us to even think about it we need it vetted by all these smart people here, confirmation that it works on PHP 4 and 5, and it follows the CI coding standards. Incidently, "shouting loud enough for the developers to hear" is not nearly as good a solution as discuss and create a fix and vet it through the community.
[eluser]Aquillyne[/eluser]
[quote author="Derek Allard" date="1216657518"]Post your code please. In order for us to even think about it we need it vetted by all these smart people here, confirmation that it works on PHP 4 and 5, and it follows the CI coding standards. Incidently, "shouting loud enough for the developers to hear" is not nearly as good a solution as discuss and create a fix and vet it through the community.[/quote] Of course. Where shall I post it? Here? Make a new wiki page? Both?
[eluser]Aquillyne[/eluser]
Here's the code changes to the Output class that enable caching of headers. Wiki entry: Cache headers: Quote:_write_cache function, around line 300 (surrounding code also shown)
[eluser]beemr[/eluser]
Woah Woah Woah Waittaminute! This is half of the code from Suffix cache, but it is the most dangerous half. If the suffix is not used as well as the header, you will overwrite the same cache file with each different mime-type. For example, if you are using your controller structure as the organizing principle behind your views and your assets (as I am), your page at example.com/welcome/index will be calling for a css at example.com/welcome/index.css and a js at example.com/welcome/index.js. Without recognition of a particular suffix for each mime-type, the next time someone links to example.com/welcome/index they will get the cached javascript. If you refuse to recognize suffixes, then you will require a separate controller for each mime-type. I don't want to see that happen to Codeigniter. Use Cache headers as a library if you must, but a core change should be DRYer than that. |
Welcome Guest, Not a member yet? Register Sign In |