recalapp / recal

First a COS 333 project, now a very popular tool at Princeton for course selection
http://recal.io
MIT License
12 stars 3 forks source link

Cache bust API urls #325

Open maximz opened 7 years ago

maximz commented 7 years ago

We should be able to cache bust API URLs to force clients to update cached versions of content. For example, when we rewrote schedules in #323, it would have been ideal to cache bust the entire courses API and all schedules.

The change would be made in CourseService.ts. Specifically, the url in this function:

    public getBySemester(termCode: string) {
        return this.$http.get(CourseService.API_URL + termCode, {
            cache: true
        }).then((response) => {
            return response.data;
        });
    }

should get a +'?v'+cache_num or something like that. This cache_num should be stored somewhere and incremented by a bust_client_cache management command. cache_num can be injected into index.html somewhere for us to pick up, since that page is never cached as it's only seen by logged-in users.

(Currently the only such thing we do is we manually have set ?bust=v4 in index.html and config.ts for loading core javascript static resources. This does not include API calls.)