If you’re gearing up to travel this Fourth of July weekend, you’ve probably noticed that gas is pricey. Boston area gas prices are currently averaging $3.78 a gallon, more than 20 cents higher than this time last year.

In fact, gas prices across the country are at their highest for a Fourth of July weekend since 2008.

"Listen to all those beeps," said one woman at a gas station at a gas station in Brighton. "Can you see the money flowing out, flowing out into the car? There it goes, dollars, going through this hose into the car.

Why does the price of gasoline change so drastically and so frequently?

"It's a very, very volatile product because how much worldwide trading there is in it," said Tom Kloza, the chief gas analyst for GasBuddy, a website that tracks gas prices.

"Literally, when you see a transport truck pass you on the road, it my be carrying $35,000 worth of gasoline at the moment, and a few hours later that might be with $37,000," Kloza said.

It all starts with the cost of crude oil, which can fluctuate wildly and quickly on the worldwide market. Gas is primarily made up of crude, so when world events drive up crude’s price, so goes the cost of a gallon of gas.

"Right now, I think most people, if put on a lie detector test, would say that there’s somewhere between $10 to $20 a barrel of a speculative worry premium, mostly attached to fears about Iraq but also fears about Iran," Kloza said.

But crude isn’t always to blame.

"Once you get beyond the price of crude, refiners have to manufacture it and make it into gasoline," Kloza said.

Demand for gas goes up in the summer, so refiners can charge a bit more. Plus, during warm weather months, making gas is a little more complicated — and more expensive.

"It’s like cake made up of different flours," Kloza said. "And during the summertime, because of ozone problems and noxious emissions, you can’t use certain components in the gasoline or they’ll have to much vapor or pressure, so you’re essentially limited to using, metaphorically, only gluten-free flour during the summertime."

Then you have to get the gasoline from the refinery to the gas station. That’s not free.

"It gets distributed through oil distributors and dealers," Kloza said. "They can add just a few pennies to it."

And, of course, there’s the taxman. In Massachusetts, that’s another 23 cents on every gallon, which is actually middle of the pack compared with other states.

Finally, there’s the station where you actually fill up. The owner of that station is the last guy in the supply chain, and the low man on the totem pole when it comes to profits, making just 2 to 3 cents on each gallon.

"It’s not like how it was back in the '50s and '40s and '30s when a couple of cents meant something," said Kishore Sanariya, who manages an Irving gas station in Boston. "Even though the price of gas has gone up, the profit margin has not. So it’s a couple of cents, but that’s not net, that’s still gross. After net, you’re probably making like half a penny on a gallon."

Here in Massachusetts, Kloza said there’s another thing that drives prices up- we don’t have the big-box stores like Krogers that also sell gas.

"The model for these places is to sell gasoline for no profit to basically get people inside the box," Kloza said. "Massachusetts does not have the same concentration of big-box stores or new era retailers, so prices tend to be more with the model of the old time 'Ma and Pa' major retailers."

Kloza said that the long-term prospect for gas prices is actually pretty good, largely because of the shale oil boom here in the U.S., but there’s a dark cloud looming in that blue sky for us here. We buy a good chunk of our gas from refineries in Europe, many of which are going out of business.

"It may move to being one of the more higher-priced regions of the country on a relative basis," Kloza said. "New England might be a bit more like California than it has been for the previous 20 years."

For the record, the average cost of a gallon of gas in California right now? It's $4.13.