react-chatbotify
react-chatbotify copied to clipboard
Cache themes and retrieve from cache when available
Description
This pull request caches the theme data with an expiry date of 30 days to local storage. If a theme exists it is returned and no call to the CDN to get the theme are made
Closes #85
What change does this PR introduce?
Please select the relevant option(s).
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update (changes to docs/code comments)
What is the proposed approach?
To resolve this issue I simply added cache setting/getting functions in order to check for a cached theme before going to the CDN. If there is no cached theme or it is expired, a call to the CDN is made and the result is then cached for future use. I chose 30 days as an arbitrary number but we can expand or reduce that as needed
Checklist:
- [x] The commit message follows our adopted guidelines
- [x] Testing has been done for the change(s) added (for bug fixes/features)
- [x] Relevant comments/docs have been added/updated (for bug fixes/features)