Welcome Guest, Not a member yet? Register   Sign In
Output cache ignores headers
#1

[eluser]Phil Sturgeon[/eluser]
So, I was half way through my REST Server screencast after about 4 attempts and it was going perfectly. Then I notice that when I enable Output cache for my REST data, it forgets the HTTP Content-type header altogether.

So all of my XML, CSV, JSON, etc data is being remembered (yay) but is being sent as text/plain which totally screws with the REST Client.

Problem!

How to get this working? This something I will have to fix myself?
#2

[eluser]elvix[/eluser]
There's an extension to Output in the wiki (i Googled for "codeigniter output cache headers"), that supposedly addresses this. I haven't used it, but it's worth a look. Smile
#3

[eluser]Colin Williams[/eluser]
This came up long ago and was fixed by the community, as elvix alluded to. I seem to remember EllisLab expressing some concerns with the solution (maybe the wiki explains some of the drawbacks) but it might work out for you.
#4

[eluser]Phil Sturgeon[/eluser]
The main issue with this (that I spotted in my brief encounter with it last night) is that it uses only the URL as the basis for the cache name.

If I use this on my REST server and somebody requests the same URL with a different MIME type, they could end up having XML sent to their JSON parser, etc. Nightmare!

Also im not sure how well this would work for authentication as it would probably send back the cached content directly without even worrying about checking the HTTP Digest/HTTP Basic authentication in the controller.

Perhaps using the Output library for my REST work is not the way to go.
#5

[eluser]beemr[/eluser]
Exactly my problem with the solution as it has evolved. My original extensions included the URI in order to add suffixes to the solution. It adds a liittle suffix sensitvity to URI then it adds the suffix to the URI before MD5ication and a contrnt-type to the cache file. From the controller side, you can get the suffix attribute and fork your views.

The pattern was based on Rails' Content-type Negotiation. No more cache collision. No duplicated controllers. Works well with a super-controller pattern. Last update I made was to bring it forward to CI 1.7.

Yoursite.com/members => standard CI web page
Yoursite.com/members.css => css particular to above page
Yoursite.com/members.xml => same controller with rss view

EDIT: It took a bit to find it in the new Wiki structure. Here: Suffix Cache




Theme © iAndrew 2016 - Forum software by © MyBB