I have indeed left caches where the PCT crosses a road both in Oregon and in Washington State. I used five-gallon buckets with lids as the primary cache container. I make sure the contents are well bagged up in ziplocs, often multiple layers of ziplocs. Additionally, I place the entire bucket inside a black plastic garbage bag. Smaller animals can't get in if you do it right. And if the contents are swathed in enough layers of plastic, the food will still have a smell a bear can detect easily from nearby, but the aroma ought not attract bears from any great distance.
As mentioned, I always look for places near to a parking area, somewhere frequently visited by humans so as to discourage bears approaching. I hide them out of sight of people, for example in a hollow stump, in among thick bushes, shoved among boulders with other rocks on top to disguise it. I also labeled each bucket on the outside to identify what it is and request it not be disturbed. I indicate when it is expected to be emptied and when it should be picked up again and removed from the site.
This has worked well for me so far. I've laid a total of six such caches in the past. None has been disturbed when I tapped into them for my resupply.
I would not recommend taking this approach anywhere in California, due to the different attitude among CA bears toward areas where humans gather. A plastic five-gallon bucket just won't suffice to keep a bear out of it. The whole key is that the bears in the vicinity must be shy of humans and not in the habit of getting near where the cache is laid.
One more thing: it is against regulations to leave any caches within the boundary of a designated wilderness area.