相关疑难解决方法(0)

htaccess利用浏览器缓存图像和CSS

我正在尝试为我的网站创建一个htaccess文件,pageSpeed的见解表明有图像和一个css文件没有过期.

我不知道从哪里开始或如何做到这一点,我从在线教程得到这个代码,并想知道这是否足够工作.

<IfModule mod_expires.c>
ExpiresActive On
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 1 year"
</FilesMatch>
</IfModule>
Run Code Online (Sandbox Code Playgroud)

或者这段代码是否符合我的需要呢?

谢谢

apache .htaccess

26
推荐指数
3
解决办法
7万
查看次数

NSURLCache 和 NSURLSession 一起不尊重:Cache-Control: max-age:86000, private, must-revalidate

在 AppDelegate.m 中,我配置了:

NSURLCache *sharedURLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 diskCapacity:100 * 1024 * 1024 diskPath:@"FhtHttpCacheDir"];
Run Code Online (Sandbox Code Playgroud)

然后是http请求:

- (void) testRestfulAPI{
    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:config];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://192.168.0.223:8000/v1/topictypes"]];

    [request setHTTPMethod:@"GET"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];

    NSError *error = nil;
    if (!error) {
        NSURLSessionDataTask *downloadTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            if (!error) {
                NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
                if (httpResp.statusCode == 200) {
                    NSDictionary* json = …
Run Code Online (Sandbox Code Playgroud)

http-caching nsurlcache ios nsurlsession

6
推荐指数
1
解决办法
1610
查看次数

标签 统计

.htaccess ×1

apache ×1

http-caching ×1

ios ×1

nsurlcache ×1

nsurlsession ×1