def custom_404(request, template_name='404.html'):
 context = {'legacy_path': legacy_path(request.path), 'download_path': reverse('download:download'), 'doc_path': reverse('documentation'), 'pypi_path': PYPI_URL}
 response = render(request, template_name, context)
 response['Cache-Control'] = 'max-age=300'
 response.status_code = 404
 return response

def custom_404 ( request , template_name = '404.html' ) : context = { 'legacy_path' : legacy_path ( request . path ) , 'download_path' : reverse ( 'download:download' ) , 'doc_path' : reverse ( 'documentation' ) , 'pypi_path' : PYPI_URL } response = render ( request , template_name , context ) response [ 'Cache-Control' ] = 'max-age=300' response . status_code = 404 return response
custom 404 handler to only cache 404s for 5 mintues .