I need to mount a tmpfs on a folder like /home/mysite.com/cache but this folder can be delete or changed by a user, but I don't want that the mounted filesystem become broken.
Then if the user moves this folder to /home/mysite.com/cache_old and recreate a folder /home/mysite.com/cache, the mount point (with tmpfs) stays ready. Also, even this folder doesn't exists at the start of the system, the tmpfs become ready if this folder is created after.
Is there a way to do it ?
Use symlinks. The parent directory of a mount-point should be root-owned and have rwxr-xr-x or more stringent permissions.
As a side note, you can chmod the actual mount-point to r-xr-xr-x before it becomes mounted. If you mount it, the permissions would be overlaid by the mounted inode - you can chmod it to something else like rwxrwxrwx.