New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add caching for theme yaml file #8202
Conversation
jocel1
commented
Jul 31, 2017
•
edited by aleeks
edited by aleeks
Questions | Answers |
---|---|
Branch? | develop |
Description? | Add caching for theme yaml file to speed up load time |
Type? | improvement |
Category? | BO |
BC breaks? | no |
Deprecations? | no |
How to test? | Load a product page |
} | ||
|
||
if ($this->filesystem->exists($jsonConf)) { | ||
$data = $this->getConfigFromFile($jsonConf); | ||
} else { | ||
$data = $this->getConfigFromFile($dir.'/config/theme.yml'); | ||
file_put_contents($jsonConf, json_encode($data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use the dumpFile()
function from the class Filesystem?
The instance is available in $this->filesystem
.
So you're telling me the cache was never created, although we always checked it? |
Only if there's no preexisting shop-specific json files. (it occurs after an upgrade for example) |
I'm wondering if the other unlink/dump occurrences of these Json files are useful, because they will be created by this getInstanceByName() anyway. By the way, could we add a check with the file timestamps? This would allow us to regenerate the json file as soon as the YML file is modified. And we can also check the environment in order to to this only in dev mode. |
right about the cache invalidation. I can modify as well saveTheme() to just invalidate the cache instead of regenerating it. |
After reading again the code, I don't think my fix introduce any potential regression. However, I need to check why the saveTheme() is not called after a migration, the real fix which needs to be done is perhaps here. |
Hello @jocel1 |
8868a2a
to
ca95940
Compare
Yeah, and it seems it could be better here. Once you import a theme, the data modified in the yml config file is never taken in account, which keeps stale data loaded during the development. |
Actually I have checked, and the issue only occurs if the upgrade is run in command line without a theme upgrade. The case in this PR will probably never happen for real. But yet it could be useful to create a JIRA to track the cache invalidation issue |
Thank you @jocel1 |
Actually the case in this PR occurs for real, when the cache is purged, or the codebase is redeployed without any cache files. In this case the theme cache is never regenerated, and the application performance is poor (I've encounter the case with a real customer). |
There will be no more releases for 1.7.2.x except for critical security fixes. |
That's a shame, if we clear the cache, we loose columns settings, also undefined variables during AJAX requests, these are critical bugs... |
@kpodemski we can discuss about it on Gitter if you want to |