Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set a cache expiration time of 60 seconds.
Supabase
const { data, error } = await supabase.from('items').select('*').cache({ ttl: [1] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 disables caching instead of setting expiration.
Choosing a very high number causes stale data.
✗ Incorrect
Setting ttl to 60 means the cache will expire after 60 seconds.
2fill in blank
mediumComplete the code to enable cache for the query.
Supabase
const { data, error } = await supabase.from('users').select('*').[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
noCache() disables caching.Using
clearCache() removes cached data.✗ Incorrect
The cache() method enables caching for the query.
3fill in blank
hardFix the error in the cache invalidation code.
Supabase
await supabase.cache.[1]('users');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
clearCache is not a valid method.Using
refreshCache does not exist in Supabase.✗ Incorrect
The correct method to invalidate cache for a table is invalidateCache.
4fill in blank
hardFill both blanks to create a cache with a 5-minute expiration and force refresh.
Supabase
const { data, error } = await supabase.from('products').select('*').cache({ ttl: [1], forceRefresh: [2] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 60 seconds instead of 300 for 5 minutes.
Setting forceRefresh to false does not force reload.
✗ Incorrect
TTL of 300 seconds equals 5 minutes. Setting forceRefresh to true forces fresh data.
5fill in blank
hardFill all three blanks to cache a query with a 10-minute TTL, disable force refresh, and specify a cache key.
Supabase
const { data, error } = await supabase.from('orders').select('*').cache({ ttl: [1], forceRefresh: [2], key: '[3]' }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using true for forceRefresh when disabling is needed.
Using a numeric value instead of a string for the cache key.
✗ Incorrect
TTL 600 seconds equals 10 minutes. forceRefresh false disables forced reload. The cache key is a string identifier.