Skip to content

Commit

Permalink
STEP 3 categories cache first
Browse files Browse the repository at this point in the history
  • Loading branch information
clementdubois committed Nov 6, 2019
1 parent 08028dc commit 1d0ea1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/services/octotv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const getCategoryInformations = async (id) => {
}
}

// the api call will be cached (cache first)
const getCategories = async () => {
try {
const result = await axios.get(`${OCTO_VHS_API}/categories`)
Expand Down
11 changes: 10 additions & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ module.exports = {
runtimeCaching: [
{
urlPattern: new RegExp(`^${urlAPIToCache}$`),
handler: 'networkFirst',
handler: 'NetworkFirst',
options: {
cacheableResponse: {
statuses: [0, 200]
}
}
},
{
urlPattern: new RegExp(`^(${OCTO_VHS_API}/categories)`),
handler: 'CacheFirst',
options: {
cacheableResponse: {
statuses: [0, 200]
Expand Down

0 comments on commit 1d0ea1a

Please sign in to comment.