Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:51:09+00:00 2026-06-12T20:51:09+00:00

Note: Now that I know where the issue comes from, I modified the question.

  • 0

Note: Now that I know where the issue comes from, I modified the question. It now contains only the information needed.

I’m new to the Laravel PHP framework.

I have a very small app working on my computer. It is connected to a MySQL database and has a User model. I use the Auth class to log in and out.

Everything works fine, but when I am logged in, loading a page takes about a second which is very slow. When I’m not logged in, it’s a matter of milliseconds.

By using the built-in profiler, I realized two problems. First, like I said, loading a page takes a bit more than 1000 milliseconds. Second, the framework makes one SQL every time I load a page when I’m logged in. The query searches a user with a certain id (my id). I guess it is there to get information about the logged in user. But isn’t there supposed to be some sort of cache. Will this be a problem if my website will have to manage many requests per seconds.

I realized that using Auth::check() in the view is what is causing the issue. I have around 4 Auth::check() is my Blade view. When I have none, it goes fast. If I have one, it is slow. Then, no matter how many I have, it doesn’t get much slower. It’s like if the Auth class’ initialization takes too much time or something like that. I guess it explains why it only happens when I’m logged in.

I dived into Laravel’s code and I found out that when Auth::check() is called for the first time, the Auth class needs to “activate” my Session by retrieving the user’s info from the database. That explains the query being executed every page request. But since the profiler says that the query doesn’t even take a millisecond to execute, I still don’t know why it slows down the app.

New information: Even when I’m not sending a query to the database, the simple act of connecting to it takes almost a second. This is the reason it is slow. I think I’m getting really close to solve the issue.

Any idea so far?

Thanks in advance.

Notes

  • The fact that Auth::check() is in the view doesn’t change anything.
  • Using another method like Auth::guest() doesn’t solve the issue.
  • New: Connecting to the database is what is slow.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:51:11+00:00Added an answer on June 12, 2026 at 8:51 pm

    I finally found a way to fix this.

    When reading some posts on many forums about XAMPP, MySQL, and PHP, and I read somewhere that it is preferable to use 127.0.0.1 because locahost needs an extra DNS lookup.

    In the database configuration file, I simply changed locahost for 127.0.0.1.

    Now everything is fast.

    I find this really strange. Using locahost in the configuration file used to make the database connection take more than a second!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note that this question is from 2008 and now is of only historic
Note: Now that I've typed this out, I have to apologize for the super
Note, this is not a duplicate of .prop() vs .attr() ; that question refers
NOTE: This is a followup to my question here. I have a program that
Note that I'm really looking for an answer to my question. I am not
I know there are already articles that covered this, but I'm having an issue
I am supervising a project done by two students that involves retrieving information from
I am having an issue with core data and I should note that I
Short version of question: How do I get started with C programming? Note that
Before answering, please note that this is a client side issue and not a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.