While UV radiation is a risk factor for skin cancer, moderate sun exposure is essential for the production of vitamin D, which is important for bone health and may have protective effects against certain cancers. It is generally recommended to get about 10 to 30 minutes of sun exposure several times a week, depending on skin type and geographical location. Using sunscreen and wearing protective clothing can help minimize the risk of skin cancer while allowing for safe sun exposure.