Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-http-cache-r
Advanced tools
React Native http cache control for both fetch/XMLHttpRequest and ImageView
由于原来仓库react-native-http-cache不再维护,导致高版本无法安装使用。 参照网上各种帖子,修复了一个版本,经测试 "react-native": "0.63.4"是可以使用的。
$ npm install react-native-http-cache-r --save
$ react-native link react-native-http-cache-r
# ios
$ cd ios & pod intall
import * as CacheManager from 'react-native-http-cache';
CacheManager.getCacheSize().then(res => {
console.log('cache size', res)
});
CacheManager.clearCache()
react-native-http-cache
library from your node_modules/react-native-http-cache/ios
folder like its
described here.
Don't forget to add it to "Build Phases" of project.android/settings.gradle
include ':RCTHttpCache'
project(':RCTHttpCache').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-http-cache/android')
android/app/build.gradle
in section dependencies
...
dependencies {
...
compile project(':RCTHttpCache') // Add this line only.
}
MainApplication.java
...
import cn.reactnative.httpcache.HttpCachePackage;
// Add this line before public class MainApplication
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new HttpCachePackage(), // Add this line
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
-keep class com.facebook.cache.disk.DiskStorageCache {
private boolean maybeUpdateFileCacheSize();
}
import * as CacheManager from 'react-native-http-cache';
// invoke API directly when in need
CacheManager.clear();
Clear cache for all type.
Return a promise which indicate the clear state.
Get cache size for all type.
Return a promise that contain the cache size(in bytes).
Clear cache for fetch/ajax only.
Return a promise which indicate the clear state.
Get cache size for fetch/ajax only.
Return a promise that contain the cache size(in bytes).
Clear cache for ImageView only.
Return a promise which indicate the clear state.
Get cache size for ImageView only.
Return a promise that contain the cache size(in bytes).
FAQs
Control http cache used by fetch/XMLHttpRequest
We found that react-native-http-cache-r demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.