Welcome Guest, Not a member yet? Register   Sign In
Specfic Question Regarding CI Caching
#1

[eluser]dimensionmedia[/eluser]
This will probably be a stupid question, but at least it should be easily answered.

Say I have a page like:

http://www.xyz.com/index.php/feeds/json

I know that view can be cached but does CI also cache the variables/uri, say like:

http://www.xyz.com/index.php/feeds/json/feed1/10
http://www.xyz.com/index.php/feeds/json/feed2/20
http://www.xyz.com/index.php/feeds/json/feed3/5

etc.

Does all of those get cached or is it just one file?

Hopefully this makes sense. I'm looking to cache output like this.
#2

[eluser]TheFuzzy0ne[/eluser]
[quote author="dimensionmedia" date="1209373282"]This will probably be a stupid question, but at least it should be easily answered.

Say I have a page like:

http://www.xyz.com/index.php/feeds/json

I know that view can be cached but does CI also cache the variables/uri, say like:

http://www.xyz.com/index.php/feeds/json/feed1/10
http://www.xyz.com/index.php/feeds/json/feed2/20
http://www.xyz.com/index.php/feeds/json/feed3/5

etc.

Does all of those get cached or is it just one file?

Hopefully this makes sense. I'm looking to cache output like this.[/quote]

I'm guessing here, because no-one else has answered your question yet. I would have to say that it will cache the way you want it to. The only real way to find out, of course, would be to just try it.
#3

[eluser]sophistry[/eluser]
the whole URI is used to generate an md5 hash that operates as the cache key. check out the CI cache library code - it's really a very simple approach.

the cache functions can be seen at the bottom of this SVN page:
http://dev.ellislab.com/svn/CodeIgniter/...Output.php

search the page for md5 and you'll see how it's done.

GL.
#4

[eluser]dimensionmedia[/eluser]
@sophistry Thanks for the confirmation - very interesting. This is certainly a big help for what's i'm doing.
#5

[eluser]nmweb[/eluser]
The md5 hash of the URI is indeed used as the cache key. This also leads to the issue that fabricated urls (leading to 404's) also are cached. Say example.com/article/view/1/title-of-the article brings you to article with id=1. With caching enabled example.com/article/view/1/another-title, article/09809 etc. ad infinitum, will also trigger caching. I believe the cache is stored in one dir so if an insane amount of urls are cached this might lead to slowdowns or the gradual filling of the harddisk. Both of which are undesirable. I believe this issue is not yet resolved.
#6

[eluser]sophistry[/eluser]
@nmweb... yes, the cache files are all stored in one dir: cache

But, AFAICT by looking at the source code the triggering of 404 errors is separate from cache writing functions. If I am not mistaken in my cursory glance, the 404 is triggered before any calls to _display() are made. i don't have a tracer so my step through was visual only.

Have you seen this cache-file-pile-up in the most recent CI version?

curious to know if you can supply code that demonstrates that 404s cause cache files to be written... i have not seen this issue, but i do not use the cache set up extensively either.
#7

[eluser]nmweb[/eluser]
There was a proof-of-concept for a previous CI version and it is not resolved in any changelog I'm aware of. It might very well be that it isn't triggered on 404's. Still, with example.com/article/view/1/another-title where the second argument is ignored and only there for SEO purposes and therefore no 404 will be triggered on changing it it will also cache. E.g. example.com/article/view/1/asffasd, example.com/article/view/1/ijoj2 will trigger the cache while all referring to the same page.

Perhaps some garbage collection could be done in 1/1000 requests so CI will loop over all caches and check for expiration. It is my understanding that files not requested will also not be checked for expiration.

For those using page caching this is certainly an issue to be aware of (and thus also check SEO url segments for correctness).
#8

[eluser]taviroquai[/eluser]
Hi! I'm not sure if I'm posting in the right topic but the behavior of my problem seems related to uri and cache...

Recently, i've checkout my project (based on CI of course) into my new ubuntu and there is one URI that no matter i change the name of the function, CI returns a 500 page error...

I'm using folder/controller/function and all of them are ok, except this one:

The html
Code:
<a href="ajaxCall('countries/cmycountry/leaderrules', null, 'all_content')">Leader Rules</a>

From firebug:
http://localhost/~mafonso/dw002/trunk/co...eaderrules
500 Internal Server Error

The result CI html:

An Error Was Encountered

Unable to load the requested file: play/countries/leader_rules.php


Is this a cache problem? How can i clean it?
There are any special permittions that i need to set on some specific folder?

System:
Linux 2.6.32-22-generic
PHP 5.3.2
CI 1.7.2
#9

[eluser]taviroquai[/eluser]
No help? Sorry about repeating but this may be simple to some of you... please read above.

Thank you!
#10

[eluser]taviroquai[/eluser]
Resolved! Yeah... it was very simples... nothing to do with caching... in my last commit i forgot to add this "leader_rules.php" view file Confused that's why CI could'nt find it!

Sorry about my posts... Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB