indexer
indexer copied to clipboard
Normalize query params, to optimize for CDN caching
With query params, it's very easy for two identical queries to not share the same cache key. For example, if a default parameter is passed or not, or the ordering of params. We should try to limit options, in order avoid this. Some ideas to consider:
- Fixed page size (limit)
- Get pages based on page number, rather than offset
- Move query params into the route, to enforce an ordering
- Require params to be sorted alphabetically (alternative to above)
- Require all params to be explicitly passed (no defaults)
- Compress set schemas (contract+token, collection, collection+attribute(s)) into a single field that can be part of the route
- Only allow certain sort directions. E.g. rare to need to sort tokens by price desc
Potentially some of the stricter rules (e.g. alphabetical params) can be an option that you can toggle on or off, depending if you want to optimize for cacheability for flexibility.
We can also add helpers to the SDK if needed, like sorting the query params. Maybe we should move the auto-generated types file into the SDK too....