0

I am working on a project that uses Angular1, we hit the problem where when we change an html template the users will not see the change until a hard refresh is performed. Ideal would be to have the cache service to check a timestamp and invalidate the cached file. As an example now I edited a template used by the $stateProvider.

My questions is what solutions or best practices are used to solve the problem?

P.S since our JS files are combined in 1 file we fixed the problem there by appending a timestamp in the script tag from our PHP backend

1 Answer 1

1

Interesting question! We've had the same issue in a project that uses Angular1.x. We solved it using angular-cache-buster.

It basically helps you put a httpInterceptor. All you need is have ngCacheBuster in module dependency injection, and inject httpRequestInterceptorCacheBusterProvider in the .config of your app to set the match list.

For example,

httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*api.*/], true);

this tells it to cache everything except REST api requests. You can learn more about the configuration here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.