Cache class prefix wrong when access different domains

27 views
Skip to first unread message

Summer White

unread,
Jul 18, 2017, 2:34:30 AM7/18/17
to f3-fra...@googlegroups.com
By default Cache uses SEED which is generated using php SERVER_NAME global variable.

When accessing a website from localhost/ vs summer-pc/ it will generate a different SEED.

The correct way to solve this is to explicitly call Cache::instance()->load(DSN, SEED);

Unfourtantly this is not documented for the Cache::load documentation
https://fatfreeframework.com/3.6/cache#load

And further would you call this a bug? I understand that using SERVER_NAME creates a way to ensure when moving from a development server to a production server the development cache isn't used. But what happens if you run the website off two different domain names, that means two different Cache sets are created which is not ideal, or perhaps it might be for caching static pages.

For my case I'm using Cache class for a simple visit counter. But I also use it for skipping debug checks such as ensuring extensions are loaded, etc...

Would I be on the right track calling this a bug or is it more ideal to use SERVER_NAME.

Either way, calling Cache::instance()->load solves this completely for me.

Thoughts?

ikkez

unread,
Jul 18, 2017, 7:37:59 AM7/18/17
to Fat-Free Framework
Actually this is a feature and not a bug. Imagine you install the same script, let's say a blog, multiple times on the same machine but with different domains, because they are different blogs. The SEED is meant to grow a different Cache/Temp file storage across multiple app instances... otherwise blog-a.com would create cache entries that would be loaded by blog-b.com if they both same the same server. If you want to same the same cache for, let's say blog-a.com and blog-a.de then you basically just need to set a custom SEED var in your config before you enabled the CACHE.

Summer White

unread,
Jul 18, 2017, 11:55:19 PM7/18/17
to Fat-Free Framework
So setting base::instance->SEED = "whatever" is better than Cache::instance->load(DSN, SEED);

None of this is documented to my knowledge.
Reply all
Reply to author
Forward
0 new messages