Cache a single file

As Travis can cache directories, it is natural to assume that one can also cache single files. However, this does not seem to be the case.

I’ve found two StackOverflow questions that have this issue as well. [1] [2] Their workaround is to move the file inside and out of a directory that can be added to the cache. That is a lot of effort working around something that seems trivial to implement.

Is it possible to cache a single file? If not, could this be a potential feature?

Example:

env:
    global:
        - FILE=$HOME/foo

cache:
    directories:
        - $FILE

before_install:
    - if [[ -d $FILE ]]; then rm -rf "$FILE"; fi

script: |
    if [[ -e $FILE ]]; then
        cat "$FILE"
    else
        echo "bla-bla-bla" >"$FILE"
    fi

Test: caching, using the cache.