The issues with the compression fitting have been addressed.
The brass flange fitting, the rubber gasket, and the threaded pipe is the "toilet spud". Replacements are available if the rubber is perished or the metal parts somehow damaged.
The flange nut looks pretty well bonded to the threaded portion. Soak well with WD-40 and let it soak in. There are splines inside the spud on which one would apply an internal spud wrench to keep the threaded pipe part from turning. You may find some other chunk of metal that will wedge against the splines, which in turn can be held by a conventional wrench. Holding the spud in place, remove the flange nut with a suitable tool.
Once the flange nut is removed, push the threaded pipe part inwards, but ensure it will not fall into the toilet. The part inside the toilet is conical shaped. Pushing it inwards will give enough free play that the rubber gasket can be pulled out. Once the rubber is out, there will be enough clearance in the toilet hole that the threaded pipe part can now be removed.
Examine the parts and evaluate if replacement is necessary. If the rubber is not too far gone, it may be possible to clean it, treat it with some sort of rubber treatment, and reinstall. If the rubber is cracked, hardened, rotted, or brittle, it will need to be replaced. The nut should be tightened firmly enough to ensure the rubber seals well against the toilet, but not so tight the rubber gets pushed out of position or the toilet gets cracked or broken.
There will indeed be some type of rubber, silicone or other type of flexible materal washer thing inside the nut. The cross section picture below attempts to show how the typical compression fitting of this type works.
![enter image description here](https://i.stack.imgur.com/YzZnt.png)
As the nut tightens it compresses the "rubber" part against the end of the threaded plastic piece and around the outside of the incoming water line. Leaks can arise as from this "rubber" part getting hard and inflexible. The chorine added to water can accelerate this this problem. Over tightening the compression nut will also lead to problems. Sometimes a corrosive build up on the water tube can also lead to leak issues. Usually it is combination of all three elements and everything is OK till there is some flexure in the joint and then it starts to leak.
To fix it is suggested to replace the compression nut and the "rubber" part. If the inlet tubing is corroded then clean it up with steel wool. If the plastic threaded part is stripped from previous over tightening then you will also have to replace the fill valve assembly in the tank too. You should be able to find replacement parts at hardware or home stores. Replacement parts are usually fairly reasonable in cost.
Best Answer
A simple fix might be using white poster putty / sticky tack. If that doesn't hold, try a dab of superglue. Each of these are available at the dollar store. For a slightly more expensive option, perhaps some white adhesive silicone caulking. All of these options should hold the cap in place enough to not blow off in the wind, but stilll allow you to break open the cap again if you need to ever remove or tighten the bolts.