- 利用 Apollo Client 的缓存功能:
- 优先使用 Apollo Client 的规范化缓存(Normalized Cache)来存储和管理数据,减少不必要的网络请求。
- 理解并配置
fetchPolicy,以优化数据获取策略,例如cache-first、network-only、cache-and-network等。 - 针对频繁变动的数据,考虑使用
no-cache或cache-and-network策略,并结合订阅(Subscriptions)或轮询(Polling)实现实时更新。 - 对于列表数据,合理使用
offsetLimitPagination或cursorPagination等策略来处理分页和无限滚动,确保缓存的有效性。 - 在进行数据修改(如 Mutations)后,通过
update函数或refetchQueries来及时更新缓存,保持UI与后端数据的一致性。
Apollo GRAPHQL Apollo Caching
利用 Apollo Client 的缓存功能来提高性能
Apollo GRAPHQL Apollo Caching by liaosw97 · b8ff232
npx skillmds@latest add liaosw97/apollo-graphql-apollo-caching File contents
---name: apollo-graphql-apollo-cachingdescription: 利用 Apollo Client 的缓存功能来提高性能---- **利用 Apollo Client 的缓存功能**: - 优先使用 Apollo Client 的规范化缓存(Normalized Cache)来存储和管理数据,减少不必要的网络请求。 - 理解并配置 `fetchPolicy`,以优化数据获取策略,例如 `cache-first`、`network-only`、`cache-and-network` 等。 - 针对频繁变动的数据,考虑使用 `no-cache` 或 `cache-and-network` 策略,并结合订阅(Subscriptions)或轮询(Polling)实现实时更新。 - 对于列表数据,合理使用 `offsetLimitPagination` 或 `cursorPagination` 等策略来处理分页和无限滚动,确保缓存的有效性。 - 在进行数据修改(如 Mutations)后,通过 `update` 函数或 `refetchQueries` 来及时更新缓存,保持UI与后端数据的一致性。
liaosw97/awesome-rules-skills/tree/main/plugins/apollo-graphql/skills/apollo-graphql-apollo-caching commit b8ff232187
Frequently asked questions
Run npx skillmds@latest add liaosw97/apollo-graphql-apollo-caching in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
利用 Apollo Client 的缓存功能来提高性能 It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
liaosw97 (@liaosw97) published this skill. Their other Agent Skills are listed on their SkillMD profile.