Everyone is VERY different when it comes to digestion and ability to process food. You can canvass people here and get a huge variety of responses - all of which might work for them and fail for you. Basically - you have to try these things and figure them out for yourself.
Below I’ve listed my general approach that works very well for my typical event which is a 2.5-4 hour road race with some very high intensity work and a lot of threshold work. It is very different from how I prep for a shorter event like a crit or a time trial
Two days before - decrease fat consumption and increase carb consumption - maybe overeat my total daily calorie goal by 250-400 calories
One day before - similar to two days out, but eat maybe 400-600 more calories than my goal
Day of - eat like normal but add in a very carb centric meal around 3 hours before the race starts. For an 11 AM race start I’d eat a normal breakfast (mix of carbs and protein) whenever I got up - 6 or 630 and then a carb meal (oatmeal, sweet potatoes, some light protein) totaling another 500ish calories around 8 AM.
One hour before start - eat a bar
5 minutes before start - eat a banana and have some caffeine to it’ll hit my body before the race starts to get hard
I then start eating in the race maybe 15-20 minutes in - if it is starting easy I’ll have solids (bars/chews) until it starts to liven up a bit when I’ll switch to gels for the rest of the race (adding in caffeine gels from 1 hour on). I make sure I eat at least every 30 minutes but will eat more if I’m capable and the race pace permits it
This is what works for me and is not optimal for everyone else. I have a fairly tolerant stomach and do fine with things in my stomach for these types of efforts but others might fail
Semi-related - I also ignore the ‘stay away from fiber before races’ guidance because I eat very high fiber at all times and have never had an issue during a race. Without getting too graphic - I almost always empty myself out 2-3 times before a race so the amount of fiber doesn’t really hurt me during races