Comments (11)
I am a bit confused, I configured mine like this:
but looking at my localstorage I can only see a few files from assets and two requests being cached. All the other requests are just not being cached.
Am I doing something wrong?
You need withInterceptorsFromDi()
inside provideHttpClient()
from cashew.
@eneajaho You are welcome to open a PR 🙂
from cashew.
This is what I would recommend, as Joost stated on the angular/angular#51303, interceptors are sensitive to ordering. They should be registered in a single place.
from cashew.
Regarding registering the interceptor, I opened an issue in the Angular repo as currently there's no way to register an interceptor directly from the library if we use functional interceptors.
from cashew.
@shaharkazaz
Will do, but after I get some more information about the interceptor registering part.
Maybe we can just fallback to tell the developer to register the interceptor themselves.
So, it would be sth like:
app.config.ts
providers: [
provideHttpClient(withInterceptors([
httpCacheInterceptor // --> This will be imported from cashew
])),
provideHttpCache() // --> Register other providers.
]
from cashew.
I think you can already use it like this:
export function provideHttp(): EnvironmentProviders[] {
return [
provideHttpClient(
withInterceptors([
logInterceptor,
tokenInterceptor,
metaInterceptor,
errorInterceptor,
]),
withXsrfConfiguration({
cookieName: 'x-csrf-token',
headerName: 'X-CSRF-Token',
}),
withFetch(),
),
importProvidersFrom(
HttpCacheInterceptorModule.forRoot({
ttl: 1000 * 60 * 10,
strategy: 'explicit',
}),
),
makeEnvironmentProviders(useHttpCacheLocalStorage),
]
}
from cashew.
I am a bit confused, I configured mine like this:
but looking at my localstorage I can only see a few files from assets and two requests being cached. All the other requests are just not being cached.
Am I doing something wrong?
from cashew.
I am a bit confused, I configured mine like this:
but looking at my localstorage I can only see a few files from assets and two requests being cached. All the other requests are just not being cached.
Am I doing something wrong?You need
withInterceptorsFromDi()
insideprovideHttpClient()
I tried that, but it does not make a difference.
This is what I see in my localstorage:
But it should cache a lot more requests.
from cashew.
I don't know what changed but its working now.... Thanks!
from cashew.
could someone provide a clear example on how to configure cashew when using standalone bootstrap? Thanks on advance!
from cashew.
Seems to work with withInterceptorsFromDi
but my response headers are not existing and no longer HttpHeaders and therefore .get()
does not work.
from cashew.
Related Issues (20)
- Allow numeric values as keys HOT 1
- Update docs on how to configure cashew in module based Angular app
- HttpParams not being parsed on http Post correctly HOT 9
- withCache can not add Authorization header HOT 1
- Replace query params to http context
- Angular Universal - localstorage is undefined HOT 9
- Regression: Implicit strategy broken in v2? HOT 1
- Angular CLI reports library as CommonJS or AMD dependency HOT 3
- How to chain multiple HttpContext HOT 3
- Feature: specify max age for cached responses HOT 2
- Bug: empty observable returned when request is repeated inside it's subscriber
- TypeError when testing service with CacheBucket HOT 1
- Allow override of cache storage provider HOT 4
- Bug: When using LocalStorage for cache, clear() does not work HOT 1
- Feature: Dynamic storage target HOT 1
- Angular 14 support HOT 2
- docs: cache then refresh data
- HttpHeaders are not handled HOT 1
- docs: compatability matrix? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cashew.