DEV Community

abbazs
abbazs

Posted on

Browser has cached a 301 Moved Permanently

I'm learning django by following the Mozilla django tutorial

At the start of the project I've edited the urls.py file to have

urlpatterns = [
    path("admin/", admin.site.urls),
    path("catalog/", include("catalog.urls")),
    path("", RedirectView.as_view(url="catalog/", permanent=True)),
]
Enter fullscreen mode Exit fullscreen mode

Following the tutorial all is well and then started my lets do something myself and did exactly same as the tutorial except having different data models and then different url path etc.

urlpatterns = [
    path("admin/", admin.site.urls),
    path("recipes/", include("lend.urls")),
    path("", RedirectView.as_view(url="recipes/", permanent=True)),
]
Enter fullscreen mode Exit fullscreen mode

But this time when testing the local site by navigating to http://127.0.0.1:8000/ it was automatically getting redirected to http://127.0.0.1:8000/catalog/.
I thought may be I copied code and searched for the word catalog in my new project. I coudn't find anything. After spending crazy one hour wondering what is going wrong, except doing a reinstall of ubuntu, started searching for if anyone else would have the same issue?

Voilà landed in a stackoverflow question someone else had exactly the same issue.
The very first line of the answer said Try clearing your browser cache. because browser has cached a 301 Moved Permanently at least for those who start learning to create web apps in any framework, this is an important piece of knowledge before they clean wipe the system and reinstall everything.

Top comments (0)