it works. But now I have defined the vars "imageDir" and "cacheDir" twice, which is not very nice. Is there any solution, to use the vars defined under "components" in an action?
If a controller, your second configuration is needed. Your first configuration is used for an app component.
Whether it is a controller or an app component depends on your need. If your extension needs to interact directly with users (via controller action), then it is a controller. If it is internally used by other code, then it is an app component.
Yes, if that is your goal. However, I think it is better to make it an app component rather than a controller, unless you have very strong reason that this should be a controller.