Search code examples
bashdeploymentlaravel-8

Why new routes doesn't works after updating my website?


I have a laravel 8.75 project that is already online. I use symbolic links to change versions. Until now it works fine (several changes with success). I made a bash script to changes versions :

if [ "$#" -ne 2 ]; then

echo "Command: ./update_version old_version new_version"

else 

echo "0 - Updating version '$1' to version '$2'"

cd ~
cd laravel/

    echo "1/9 - Unlink current..."
    if unlink current ; then
        echo "1/9 - Done"
        echo "2/9 - Creation of new current symbolic link..."
        if ln -s /home/x/laravel/releases/$2 /home/x/laravel/current ; then
            echo "2/9 - Done"
            echo "3/9 - Creation of .env symbolic link..."
            if ln -s /home/x/laravel/.env /home/x/laravel/releases/$2/.env ; then
                echo "3/9 - Done"
                echo "4/9 - Copy .htaccess file..."
                if cp /home/x/laravel/releases/$1/public/.htaccess /home/x/laravel/releases/$2/public ; then
                    echo "4/9 - Done"
                    echo "5/9 - Copy storage folder..."
                    if cp -r /home/x/laravel/releases/$1/storage/app/public /home/x/laravel/releases/$2/storage/app/ ; then
                        echo "5/9 - Done"
                        echo "6/9 - Move matomo folder..."
                        if mv /home/x/laravel/releases/$1/public/matomo /home/x/laravel/releases/$2/public/ ; then
                        echo "6/9 - Done"
                            echo "7/9 - Creation of storage files symbolic link"
                            if ln -s /home/x/laravel/releases/$2/storage/app/public /home/x/laravel/releases/$2/public/storage ; then
                                echo "7/9 - Done"
                                cd /home/x/laravel/releases/$2
                                echo "8/9 - Composer install..."
                                composer install
                                    echo "8/9 - Done"
                                    # Executer les migrations
                                    echo "9/9 - Run migrations..."
                                    if php artisan migrate ; then
                                    echo "9/9 - Done"
                                    echo "Update is successful!"

                                    else 

                                    echo "9/9 - Failed to run migrations"

                                    fi
                            else

                            echo "7/9 - Failed to create symbolic link for storage files"

                            fi
                        else

                         echo "6/9 - Failed to copy matomo folder"

                        fi
                    else 

                    echo "5/9 - Failed to copy storage folder"

                    fi
                else 

                echo "4/9 - Failed to copy .htaccess"

                fi
            else 

            echo "3/9 - Failed to create symbolic link to .env"

            fi
        else 

        echo "2/9 - Failed to create new current link"

        fi
    else 

    echo " 1/9 - Failed to destroy the current link"

    fi
fi

Today I have to change version (new css file, new routes, javascript modifications...).

As always I run ./update-version old-version new-version and it works (nothing failed and the symbolic link is ok), it's my new version online (I know it because js modifications are displayed).

But for some reasons, my new routes and the new css files are not served.

In the inspector I can see that the css file on "Network" is the old one.

I run php artisan optimize:clear into the new release but it doens't change anything...

On my production server files modifications are there but not on browsers (window and inspector).

If I upload the new css file into the old release and change the stylesheet url it works.

So it has to be the files in new release which cause this but I don't know which ones...

Has anyone ever encountered this? Or does anyone have an idea where the problem could be?


Solution

  • Answer

    -> Can you please follow step below to check CSS files are not being served after updating your Laravel website

    • Your browser is caching the old files. Try clearing your browser cache and cookies
    • Your web server is caching the old files. If you are using a web server like Apache or Nginx, you may need to clear the cache.
    • Your Laravel application is still serving the old files. This could happen if you are using a route cache or if you have not deployed the new code to your production server.

    -> To troubleshoot the issue, you can try above steps:

    • Clear your browser cache and cookies.
    • Clear your web server cache.
    • Run the php artisan route:cache command to clear the route cache.
    • Deploy the new code to your production server.

    -> I think this will help you to solve the issue. If you still getting the error then check Laravel error log to understand the exact issue.