Optical response of nanostructures