derixithy Posted May 6, 2017 Share Posted May 6, 2017 I'm reusing pages depending on the url of the site and want to cache these pages. For example example.com/blog/1 and example.nl/blog/1 would use the same template but i'm extending the Page to limit the results depending on url. Is there a way that i can append a name to the cache name used to cache this page? It seems it should be easy to hook in the cache rending and change it but i could not find anything helpfull. Link to comment Share on other sites More sharing options...
derixithy Posted May 22, 2017 Author Share Posted May 22, 2017 It seems that i need to set $cacheFile->setSecondaryID after Pagerender.module has set it so i don't affect page id's and translation. If someone know how to do this properly any help is much apreciated! Link to comment Share on other sites More sharing options...
derixithy Posted May 27, 2017 Author Share Posted May 27, 2017 Is there no one who can help with this? Am i asking something very difficult? It's probably not that helpfull for others, but it didn't look that hard to do. I just don't know how to do it. -edit: some text Link to comment Share on other sites More sharing options...
Zeka Posted May 27, 2017 Share Posted May 27, 2017 Are these domains for the same site? You can try to use markup cache module and $cache for these pages where you have some dynamic content. Link to comment Share on other sites More sharing options...
derixithy Posted May 29, 2017 Author Share Posted May 29, 2017 The domains go to the same site/server. I wanted to avoid unnecessary complexity in my template code (i'm just a hobby programmer and more of a designer). Also it allows me to change it from the admin panel, which removes the necessity of re-uploading files. But i see that your route is a better way to go, then to wait for someone to help me with this niece case. Sorry for being a bit impatient with things. I can't sit long behind my desk and am long past my deadline, but that's my problem. Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 29, 2017 Share Posted May 29, 2017 https://processwire.com/blog/posts/processwire-core-updates-2.5.28/#wirecache-upgrades Link to comment Share on other sites More sharing options...
derixithy Posted June 9, 2017 Author Share Posted June 9, 2017 Markup cache is basically useless for me, i'm going to edit the Pagerender.module instead. Other suggestions are welcome Link to comment Share on other sites More sharing options...
derixithy Posted June 24, 2017 Author Share Posted June 24, 2017 You where right LostKobrakai, I was to stubborn to really listen and take advantage of your advice. Reading up about it the first time made it seem like it would work fine in my case, bringing it in to practice was a whole other thing. Saving pages to cache resulted in returning only id's after saving and sometimes a piece of code worked but a minute later it didn't, so i got really frustrated and just gave up after a while. I took a fresh look a few days later and I could fix the id problem (LazyLoading) by using $pages->findOne instead of $pages->get. Also i noticed pages where being cached somehow even if i turn it off by using // FileCompiler=0 in the top of the file, or using the following in config.php $config->debug = true; if ( $config->debug == true ) { $config->fileCompilerOptions = array( 'siteOnly' => false, 'showNotices' => true, 'logNotices' => false, 'exclusions' => array('php', 'phtml'), 'extensions' => array('php', 'module', 'inc', 'phtml'), ); $config->dbCache = false; $config->moduleCompile = true; $config->templateCompile = false; } Strangely the error page show's the updated code but still thinks there is an error.http://i.imgur.com/Dx1B0x0.png So i'm sorry for my little outburst in the comment above. Although it seemed simpler to set the secondaryID in my mind, this solution is a whole lot more powerful. Link to comment Share on other sites More sharing options...
LostKobrakai Posted June 25, 2017 Share Posted June 25, 2017 You disabled everything for the fileCompiler, but wireCache and the fileCompiler are two totally different things. The first one is a multiple purpose cache for data you handle in your code. The fileCompiler is there to dynamically add the ProcessWire namespace needed in php files since pw 3.0, a.k.a. it's literally changing your php files and is not a cache for data at all. You could do this: // in config.php $config->cacheTimeMultiplier = 1 if($config->debug) $config->cacheTimeMultiplier = 0 // elsewhere echo $cache->get("hello-world", 3600 * $config->cacheTimeMultiplier, function() { echo "<p>Hello World</p>"; }); 2 Link to comment Share on other sites More sharing options...
derixithy Posted June 26, 2017 Author Share Posted June 26, 2017 I commented out the wire cache during testing (by commenting out the code), so no problem there. Thanks for letting me know the filecompiler stuff is unnecessary, i already namespace my files so it's only needed for modules. I already gave up on the cache problem. edit: grasping at straws Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now