Limit UrlCache, make it an LRU.
See original GitHub issueWhat you will need to know
- Basic Javascript
Background
We have a utility method called parseUrl
in url.js that is used to parse a Url string.
This method caches the result of a parse so not to repeat for the same given Url however the cache used for this is unlimited which is no ideal.
Useful Hints
The fix involved changing the cache map to be an LRU (Least Recently Used)
cache with a large capacity (100
).
Fortunately we have an implementation of LRU cache in lru-cache.js which we can use here.
Step by step
- Claim this issue by adding a comment below. Please only claim this bug if you plan on starting work in the next day or so. (If you join the AMP Project we’ll be able to assign this issue to you after you’ve claimed it.)
- If you aren’t too familiar with Git/GitHub, see the Getting Started End-to-End Guide for an intro to Git & GitHub, and how to get a copy of the code. You can also refer to the Quick Start Guide for the necessary setup steps with less explanation than the End-to-End guide.
- Follow the instructions for building AMP.
- Create a Git branch for making your changes.
- Sign the Contributor License Agreement before creating a Pull Request. (If you are contributing code on behalf of a corporation start this process as early as possible.)
- Commit your changes frequently.
- Push your changes to GitHub.
- Create a Pull Request. Mention @aghassemi and
closes Issue #13280
in the description. - Respond to your reviewer’s comments (if any).
Once approved, your changes will be merged. ⚡⚡⚡Congrats on making your first contribution to the AMP Project!⚡⚡⚡ You’ll be able to see it live across the web soon!
Thanks, and we hope to see more contributions from you soon.
Questions?
If you have questions ask @aghassemi in this issue or on your Pull Request (if you’ve created one) or see the How to get help section of the Getting Started guide.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
@aghassemi awesome! I’ll start working on it tonight 👍
@aghassemi I would like to take a shot at this issue if it is free.