Can I delete particular file from firefox cache?

2019-02-22 02:29发布

I am developing an ASP.net application.

Where I have to frequently update my CSS file. I don't want to update document frequency setting in from about:config in Firefox. I want to let it default.

I use Firefox as an Ideal browser. If I just update my CSS file, I have to clear whole cache of Firefox.

I want to delete particular file from Firefox cache. Is this possible in Firefox. I can delete particular cookie in Firefox. Can't I delete particular file from Firefox cache?

If It is not possible then please tell me how can I make my CSS file in the way that it should be always checked (and only load if modified) for newer version. I do not want to change Firefox settings in any case.

4条回答
倾城 Initia
2楼-- · 2019-02-22 02:36

Add a last update time stamp to the linked file. This is what it would look like in php

<link type="text/css" rel="stylesheet" href="css/style.css?lu=<?php echo filectime('css/style.css') ?>" />

This will cause the browser to reload the file only when the file is updated.

查看更多
该账号已被封号
3楼-- · 2019-02-22 02:40

This is possible via a few lines of script (to be run on the Browser Console, Ctrl+Shift+J):

// load the disk cache
var cacheservice = Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
    .getService(Components.interfaces.nsICacheStorageService);
var {LoadContextInfo} = Components.utils.import("resource://gre/modules/LoadContextInfo.jsm",{})
var hdcache = cacheservice.diskCacheStorage(LoadContextInfo.default, true);

// compose the URL and submit it for dooming
var uri = Components.classes["@mozilla.org/network/io-service;1"]
    .getService(Components.interfaces.nsIIOService).newURI(prompt("Enter the URL to kick out:"), null, null);
hdcache.asyncDoomURI(uri, null, null);

As long as you know the absolute URL of the CSS file, you could replace prompt("Enter the URL to kick out:") with the URL.

Adapted from DoomEntry.js, confirmed to work on latest Firefox (Quantum) as well.

查看更多
Evening l夕情丶
4楼-- · 2019-02-22 02:53

If I remember correctly, the keycombination CTRL + F5 cleats the cache and the css-files have to be reloaded.

查看更多
做个烂人
5楼-- · 2019-02-22 02:55

Using an ETag would be a good option. By setting the Max-Age Header in HTTP responses, you can allow the client to cache the resource for a limited time. After that time, the client will make a conditional GET request to the server. If the ETag (stored in the If-None-Match header) in the request doesn't match the ETag on the server, the modified resource will be sent down to the client. Otherwise the server responds with HTTP 304 Not Modified and the client can cache the content for a limited time again. This approach can be used for particular files or for directories.

查看更多
登录 后发表回答