Is the FileExists function uses CFHTTP head?
Yes, fileExists
utilizes the Commons Virtual File System, which translates to a HTTP HEAD request for web resources.
What is the advantage of FileExists over CFHTTP when checking if the remote file exists?
Theoretically the implementation could easily adjust to specific rules for web resources, while using cfhttp
would be a concrete implementation. However, you could just wrap cfhttp
to easily adjust it yourself, rather than relying on the newest version of Jakarta VFS.
Also is FileExists better than CFHTTP in terms of server load?
No, right now both calls result in a HTTP HEAD request. I could not measure a real performance difference between them.
As mentioned in the comments, you should probably NOT use fileExists
, because:
- Checking web resources is not documented by Adobe, it's more like a nice side-effect because the implementation uses VFS beneath.
- You do not have any control over the implementation. Example: In case you ever need to add an additional header (because the webserver you are checking requires you to do so), you would be out of luck with
fileExists
.
So my recommendation is: Write a neat function that uses cfhttp method="HEAD"
and adjust the function whenever you need to. Don't trust an undocumented feature, especially not when it comes to CF. 😜