Repository: fsspec/filesystem_spec

Issue:
Erraneous cached file system protocol
## Problem description

When opening a file using a path chain of eg filecache and S3, the resulting filesystem has the protocol set to `(s3 , s3a)`, while I believe it should be set to `filecache`.

For example:
```python
import fsspec

filename = 'noaa-goes16/ABI-L1b-RadC/2019/001/17/*_G16_s20190011702186*'
the_files = fsspec.open_files("filecache::s3://" + filename, s3={'anon': True})

fs = the_files[0].fs
print(fs.protocol)
# prints `(s3, s3a)`

```

## fsspec version
fsspec==2025.7.0

## Context
I'm trying to convert the open_file instances to universal_pathlib's UPath for further processing, but the problematic protocol can be exhibited simply by passing the filesystem dict to fsspec's `filesystem`, eg:
```python
fs = the_files[0].fs

nfs = fs.to_dict().copy()

nfs.pop("cls")
# 'fsspec.implementations.cached:WholeFileCacheFileSystem'

fsspec.filesystem(**nfs).ls("noaa-goes16/ABI-L1b-RadC/2019/001/17/OR_ABI-L1b-RadC-M3C01_G16_s20190011702186_e20190011704559_c20190011705004.nc")
## Crashes with an AIOError...
## fsspec.filesystem(**nfs) is an instance of S3Filesystem

nfs["protocol"] = "filecache"
fsspec.filesystem(**nfs).ls("noaa-goes16/ABI-L1b-RadC/2019/001/17/OR_ABI-L1b-RadC-M3C01_G16_s20190011702186_e20190011704559_c20190011705004.nc")
## ouputs correct info
# [{'Key': 'noaa-goes16/ABI-L1b-RadC/2019/001/17/OR_ABI-L1b-RadC-M3C01_G16_s20190011702186_e20190011704559_c20190011705004.nc',
#   'LastModified': datetime.datetime(2019, 1, 1, 17, 5, 30, tzinfo=tzutc()),
#   'ETag': '"90ca35579eb2dd228ece9ada6dcba7da-2"',
#   'Size': 14537927,
#   'StorageClass': 'INTELLIGENT_TIERING',
#   'type': 'file',
#   'size': 14537927,
#   'name': 'noaa-goes16/ABI-L1b-RadC/2019/001/17/OR_ABI-L1b-RadC-M3C01_G16_s20190011702186_e20190011704559_c20190011705004.nc'}]
```


Discussion:
Yes, I think you are right: the protocol should be of the "outer" caching filesystem.
Where should I start looking to fix this? Hopefully it's not too complex, and I could give a hand.
Probably it needs "protocol" to be added to https://github.com/fsspec/filesystem_spec/blob/master/fsspec/implementations/cached.py#L425 



Patch:
diff --git a/fsspec/implementations/cached.py b/fsspec/implementations/cached.py
index dab97a2a9..4847c2ef2 100644
--- a/fsspec/implementations/cached.py
+++ b/fsspec/implementations/cached.py
@@ -478,7 +478,7 @@ def __getattribute__(self, item):
         if item in ["transaction"]:
             # property
             return type(self).transaction.__get__(self)
-        if item in ["_cache", "transaction_type"]:
+        if item in {"_cache", "transaction_type", "protocol"}:
             # class attributes
             return getattr(type(self), item)
         if item == "__class__":


Test patch:
diff --git a/fsspec/implementations/tests/test_cached.py b/fsspec/implementations/tests/test_cached.py
index c9222d5b5..011f6e50f 100644
--- a/fsspec/implementations/tests/test_cached.py
+++ b/fsspec/implementations/tests/test_cached.py
@@ -1337,3 +1337,8 @@ def test_filecache_write(tmpdir, m):
 
     assert m.cat(fn) == data.encode()
     assert fs.cat(fn) == data.encode()
+
+
+def test_cache_protocol_is_preserved():
+    fs = fsspec.filesystem("filecache", target_protocol="file")
+    assert fs.protocol == "filecache"