TL;TR;: Changing XDG_CACHE_HOME globally like with use of export will affect other apps too, not just pip alone and you do not want the mess this can cause. Do NOT do this unless really necessary!
You should be using pip's --cache-dir <dir> command line argument instead or at least, if you want to go that way, override XDG_CACHE_HOME value for pip invocation only:
XDG_CACHE_HOME=<path> pip ...
which also can be made more permanent by using shell alias feature:
alias pip="XDG_CACHE_HOME=<path> pip"
BUT... you do not need to touch XDG_CACHE_HOME at all, as pip can have own configuration file where you can override all the defaults to your liking, including alternate cache directory location. Moreover, all command line switches have accompanying env variable that pip looks for at runtime, which looks like the cleanest approach.
In your case, --cache-dir can be provided via PIP_CACHE_DIR. So you can either set it globally:
export PIP_CACHE_DIR=<path>
or per invocation:
PIP_CACHE_DIR=<path> pip ...
or create said configuration file.
See docs for more information about pip config file and variables.