Opened 13 months ago
Last modified 3 months ago
#4451 new Enhancement
elgg_get_simplecache_url & elgg_register_simplecache_view
| Reported by: | jtilson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Elgg 1.9.0 |
| Component: | Core | Version: | 1.8.3 |
| Severity: | minor | Keywords: | |
| Cc: | brett@… | Difficulty: |
Description
I'm sure this has been discussed before, but I wanted to open up an official ticket in regards to the 'registering for simplecache' process.
Right now it's a two step process: (ie: blogs)
$blog_js = elgg_get_simplecache_url('js', 'blog/save_draft');
elgg_register_simplecache_view('js/blog/save_draft');
Can't these two steps be combined?
I realize there's a warning in the comments for 'elgg_get_simplecache_url' that states that you have to call 'elgg_register_simplecache_view' in order for it to work. The problem is if a dev forgets to call the register function (ie: https://github.com/Elgg/Elgg/commit/e57ad78561dd4e80eb3621475aaade030c0fbdd0) the simplecache will be regenerated on every page load.
You can test this out on a clean install by commenting out:
elgg_register_simplecache_view('js/blog/save_draft');
in the blog plugin, and then hit the 'add blog' page. If you watch the net activity in firebug/web inspector, you can see the 'lastcache' timestamp updating on each load.
Since we're clearly warned in the code documentation to call elgg_register_simplecache_view I wouldn't call this a bug, but it'd be nice if this could be handled automatically.
- Jeff
Change History (8)
comment:1 Changed 13 months ago by jtilson
comment:2 Changed 13 months ago by ewinslow
- Milestone changed from Needs Review to Elgg 1.9.0
Sounds reasonable to me. Want to submit a pull request?
comment:3 Changed 12 months ago by Evan Winslow
Merge pull request #225 from jrtilson/fix-admin-simplecache
Refs #4451. Calls elgg_register_simplecache_view('css/admin') to register admin css with simplecache.
Changeset: 8265966f172994ce27a3f1c13f930ae9d5e5f4d0
comment:4 Changed 3 months ago by srokap
Bumping this one. I know there's some work on it being done for 1.9 to put these three functions into one, but wouldn't it be applicable for 1.8.x as well to just put elgg_register_simplecache_view inside elgg_get_simplecache_url call? It won't _break_ api and yet will help a lot of people that probably not even notice problem with simplecache.
comment:5 Changed 3 months ago by ewinslow
I tried this and unfortunately it doesn't work like you'd expect. Instead we're probably going to move to a model that is even more fully automated:
1) Caching on demand instead of full regenerate on every miss.
2) Accept static files as views and automatically cache/minify them.
comment:6 Changed 3 months ago by srokap
I'm curious what could possibly go wrong in this, instead of possibly registering unnecessary views? Only problem would be that we register more views that probably get registered via elgg_register[js|css] in simplecache. If someone does conditional registration we wouldn't make it worse than it already is.
Clarification: I'm just talking about simple fix for 1.8 branch, I like idea of making it better for 1.9.
comment:7 Changed 3 months ago by ewinslow
Like I said, I already tried. If you can get it to work how you expect, then by all means submit a pull request.
comment:8 Changed 3 months ago by srokap
It seems to work for me. I'll test it some more.

Here's another example of an overlooked elgg_register_simplecache_view:
https://github.com/Elgg/Elgg/pull/194